parent
58335da72a
commit
ced6802007
|
@ -1,2 +1,2 @@
|
|||
example-protobuf/example-protobuf
|
||||
example-cmd/example-cmd
|
||||
*.pb.go
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
build:
|
||||
go build
|
||||
./example-protobuf
|
||||
./example-cmd
|
||||
|
||||
prep:
|
||||
go get -v -t -u
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"go.wit.com/log"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
pb "go.wit.com/lib/protobuf/witProtobuf"
|
||||
"go.wit.com/lib/protobuf/witpb/guipb"
|
||||
)
|
||||
|
||||
//
|
||||
|
@ -23,7 +23,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalln("Error reading file:", err)
|
||||
}
|
||||
allEvents := &pb.Event{}
|
||||
allEvents := &guipb.Event{}
|
||||
if err := proto.Unmarshal(in, allEvents); err != nil {
|
||||
log.Error(err, "Failed to parse events:")
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func main() {
|
|||
log.Println(in)
|
||||
}
|
||||
|
||||
func marshalWriteToFile(myWriter *bufio.Writer, e *pb.Event) {
|
||||
func marshalWriteToFile(myWriter *bufio.Writer, e *guipb.Event) {
|
||||
buf, err := proto.Marshal(e)
|
||||
if err != nil {
|
||||
log.Fatal("marshaling error: ", err)
|
||||
|
@ -60,7 +60,7 @@ func marshalWriteToFile(myWriter *bufio.Writer, e *pb.Event) {
|
|||
func TestWriteEvent() {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
e := pb.CreateSampleEvent()
|
||||
e := guipb.CreateSampleEvent()
|
||||
|
||||
got := buf.String()
|
||||
log.Println(got)
|
||||
|
@ -73,13 +73,13 @@ func TestWriteEvent() {
|
|||
}
|
||||
|
||||
func marshalUnmarshal() {
|
||||
test := pb.CreateSampleEvent()
|
||||
test := guipb.CreateSampleEvent()
|
||||
data, err := proto.Marshal(test)
|
||||
if err != nil {
|
||||
log.Fatal("marshaling error: ", err)
|
||||
}
|
||||
|
||||
newTest := &pb.Event{}
|
||||
newTest := &guipb.Event{}
|
||||
err = proto.Unmarshal(data, newTest)
|
||||
if err != nil {
|
||||
log.Fatal("unmarshaling error: ", err)
|
||||
|
|
Loading…
Reference in New Issue