summaryrefslogtreecommitdiff
path: root/hashbydata.go
diff options
context:
space:
mode:
Diffstat (limited to 'hashbydata.go')
-rw-r--r--hashbydata.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/hashbydata.go b/hashbydata.go
new file mode 100644
index 0000000..83874f3
--- /dev/null
+++ b/hashbydata.go
@@ -0,0 +1,24 @@
+package main
+
+import "fmt"
+
+type (
+ empty struct{}
+ t interface{}
+ set map[t]empty
+)
+
+func main() {
+ m := make(map[t]string)
+ fmt.Println(fmt.Sprintf("%+v", m))
+ m[struct{ x string }{x: "hello there"}] = "hello there"
+ fmt.Println(fmt.Sprintf("%+v", m))
+
+ m[struct{ x string }{x: "hello there"}] = "goodbye"
+ fmt.Println(fmt.Sprintf("%+v", m))
+
+ ptr := &struct{ x string }{x: "hello there"}
+ pv := *ptr
+ m[pv] = "ptr"
+ fmt.Println(fmt.Sprintf("%+v", m))
+}