When i use the func, map slice as the key of map, it isn't work! 
     So  I lookup source  why, i find 

    // spec: "The comparison operators == and != must be fully defined
        // for operands of the key type; thus the key type must not be a
        // function, map, or slice."
        //
        // Delay this check because it requires fully setup types;
        // it is safe to continue in any case (was issue 6667).
        check.later(func() {
            if !Comparable(typ.key) {
                check.errorf(e.Key.Pos(), "invalid map key type %s", 
typ.key)
            }
        })
// Comparable reports whether values of type T are comparable.
func Comparable(T Type) bool {
    switch t := T.Underlying().(type) {
    case *Basic:
        // assume invalid types to be comparable
        // to avoid follow-up errors
        return t.kind != UntypedNil
    case *Pointer, *Interface, *Chan:
        return true
    case *Struct:
        for _, f := range t.fields {
            if !Comparable(f.typ) {
                return false
            }
        }
        return true
    case *Array:
        return Comparable(t.elem)
    }
    return false
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to