Source File
hash.go
Belonging Package
src.elv.sh/pkg/eval/vals
package valsimport ()// Hasher wraps the Hash method.type Hasher interface {// Hash computes the hash code of the receiver.Hash() uint32}// Hash returns the 32-bit hash of a value. It is implemented for the builtin// types bool and string, the File, List, Map types, StructMap types, and types// satisfying the Hasher interface. For other values, it returns 0 (which is OK// in terms of correctness).func ( interface{}) uint32 {switch v := .(type) {case bool:if {return 1}return 0case float64:return hash.UInt64(math.Float64bits())case string:return hash.String()case Hasher:return .Hash()case File:return hash.UIntPtr(.Fd())case List::= hash.DJBInitfor := .Iterator(); .HasElem(); .Next() {= hash.DJBCombine(, (.Elem()))}returncase Map::= hash.DJBInitfor := .Iterator(); .HasElem(); .Next() {, := .Elem()= hash.DJBCombine(, ())= hash.DJBCombine(, ())}returncase StructMap::= hash.DJBInit:= iterateStructMap(reflect.TypeOf()):= reflect.ValueOf()for .Next() {, := .Get()= hash.DJBCombine(, ())}return}return 0}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)