Last active
May 22, 2018 06:52
-
-
Save nukosuke/e829d15db895c8f4ffb27fde8fd285aa to your computer and use it in GitHub Desktop.
This file contains 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
package main | |
import ( | |
"bytes" | |
"crypto/md5" | |
"encoding/gob" | |
"fmt" | |
) | |
type Data struct { | |
Field1 string | |
Field2 int | |
FIeld3 bool | |
} | |
func main() { | |
d1 := Data{"てすと", 100, true} | |
d2 := Data{"てすと", 100, true} | |
buf1 := bytes.NewBuffer(nil) | |
_ = gob.NewEncoder(buf1).Encode(&d1) | |
fmt.Println(md5.Sum(buf1.Bytes())) | |
buf2 := bytes.NewBuffer(nil) | |
_ = gob.NewEncoder(buf2).Encode(&d2) | |
fmt.Println(md5.Sum(buf2.Bytes())) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gobではアドレスなどの情報が含まれていないっぽく同じ内容のデータは同じハッシュ値になる。