Created
March 30, 2020 14:55
-
-
Save psanzay/4cccaf8e811f267f583fad458e16d573 to your computer and use it in GitHub Desktop.
serializing protocol buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
person := &pb.Person{} | |
person.Name = "test" | |
.... other fields ... | |
out, err := proto.Marshal(person) | |
// writing to file | |
if err != nil { | |
log.Fatalln("Failed to encode person:", err) | |
} | |
if err := ioutil.WriteFile("phones", out, 0644); err != nil { | |
log.Fatalln("Failed to write person:", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment