Example #1
0
// typeBaseType returns the base type for a types.Type.
func typeBaseType(t types.Type) types.Type {
	switch t := t.(type) {
	case *types.Array:
		return typeBaseType(t.Elem())
	case *types.Pointer:
		return typeBaseType(t.Deref())
	case *types.Map:
		return typeBaseType(t.Elem()) // TODO(sqs): also return Key type; typeBaseType needs to return multiple results?
	case *types.Slice:
		return typeBaseType(t.Elem())
	}
	return t
}