Skip to content

Instantly share code, notes, and snippets.

@yifan-gu
Created March 17, 2014 19:56
Show Gist options
  • Save yifan-gu/9606979 to your computer and use it in GitHub Desktop.
Save yifan-gu/9606979 to your computer and use it in GitHub Desktop.
== in golang
package main
import (
"fmt"
)
type obj struct {
a int
}
func main() {
o1 := &obj{1}
o2 := &obj{2}
o3 := &obj{1}
fmt.Println(o1 == o1)
fmt.Println(o1 == o2)
fmt.Println(o1 == o3)
m := make(map[int]*obj)
m[1] = o1
a := m[1]
fmt.Println(&a, &o1)
fmt.Println(a == o1)
fmt.Println(a == o3)
}
@yifan-gu
Copy link
Author

result:

true
false
false
0xc210000038 0xc210000018
true
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment