package object import "hash/fnv" type Hashable interface { HashKey() HashKey } type HashKey struct { Type ObjectType Value uint64 } func (b *Boolean) HashKey() HashKey { var val uint64 = 0 if b.Value { val = 1 } return HashKey{Type: b.Type(), Value: val} } func (i *Integer) HashKey() HashKey { return HashKey{Type: i.Type(), Value: uint64(i.Value)} } func (s *String) HashKey() HashKey { h := fnv.New64() h.Write([]byte(s.Value)) return HashKey{Type: s.Type(), Value: h.Sum64()} }