Skip to content

Instantly share code, notes, and snippets.

@yifan-gu
Created January 5, 2014 22:03
Show Gist options
  • Save yifan-gu/8274539 to your computer and use it in GitHub Desktop.
Save yifan-gu/8274539 to your computer and use it in GitHub Desktop.
about gogoprotobuf on slice when len = 0
type A struct {
slice []int
}
a = &A{make([]int, 0)}
bytes, _ := a.Marshal()
b := new(A) // b.slice == nil
b.Unmarshal(bytes)
re := reflect.DeepEqual(a, b) // re == false, because b.slice == nil, but a.slice != nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment