Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Proto messages
- message TestMsg
- {
- bool param = 1;
- }
- // TEST wrapper
- message TheInnocentNotification
- {
- bool is_everything_ok = 1;
- }
- message TheMessageOfDoom
- {
- bool destroy_everything = 1;
- }
- // The code
- testMsg := &protoMsg.TestMsg{
- Param: true,
- }
- testMsgBin, _ := testMsg.Marshal()
- fmt.Printf("<%s>\n", fmtBits(testMsgBin))
- innocentMsg := &protoMsg.TheInnocentNotification{}
- proto.Unmarshal(testMsgBin, innocentMsg)
- doomMsg := &protoMsg.TheMessageOfDoom{}
- proto.Unmarshal(testMsgBin, doomMsg)
- fmt.Println("innocentMsg", innocentMsg.GetIsEverythingOk()) // returns true
- fmt.Println("doomMsg", doomMsg.GetDestroyEverything()) // returns true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement