-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_scan_test.go
71 lines (64 loc) · 1.37 KB
/
example_scan_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package proio_test
import (
"bytes"
"fmt"
"github.com/proio-org/go-proio"
model "github.com/proio-org/go-proio-pb/model/example"
)
func Example_scan() {
buffer := &bytes.Buffer{}
writer := proio.NewWriter(buffer)
for i := 0; i < 8; i++ {
event := proio.NewEvent()
p := &model.Particle{
Pdg: int32(11 + i),
}
event.AddEntry("Particle", p)
writer.Push(event)
}
writer.Flush()
reader := proio.NewReader(buffer)
for event := range reader.ScanEvents(10) {
fmt.Print(event)
}
// Output:
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 11
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 12
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 13
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 14
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 15
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 16
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 17
//
// ---------- TAG: Particle ----------
// ID: 1
// Entry type: proio.model.example.Particle
// pdg: 18
}