package valsimport ()// HasKeyer wraps the HasKey method.typeHasKeyerinterface {// HasKey returns whether the receiver has the given argument as a valid // key.HasKey(interface{}) bool}// HasKey returns whether a container has a key. It is implemented for the Map// type, StructMap types, and types satisfying the HasKeyer interface. It falls// back to iterating keys using IterateKeys, and if that fails, it falls back to// calling Len and checking if key is a valid numeric or slice index. Otherwise// it returns false.func (, interface{}) bool {switch container := .(type) {caseHasKeyer:return .HasKey()caseMap:returnhashmap.HasKey(, )caseStructMap:returnhasKeyStructMap(, )casePseudoStructMap:returnhasKeyStructMap(.Fields(), )default:varbool := IterateKeys(, func( interface{}) bool {if == { = true }return ! })if == nil {return }if := Len(); >= 0 {// TODO(xiaq): Not all types that implement Lener have numerical // indices , := ConvertListIndex(, )return == nil }returnfalse }}func ( StructMap, interface{}) bool { , := .(string)if ! || == "" {returnfalse }for , := rangegetStructMapInfo(reflect.TypeOf()).fieldNames {if == {returntrue } }returnfalse}
The pages are generated with Goldsv0.2.8-preview. (GOOS=darwin GOARCH=arm64)