func typeStr(obj *ast.Object, typ types.Type) string { switch obj.Kind { case ast.Fun, ast.Var: return fmt.Sprintf("%s %v", obj.Name, prettyType{typ}) case ast.Pkg: return fmt.Sprintf("import (%s %s)", obj.Name, typ.Node.(*ast.ImportSpec).Path.Value) case ast.Con: if decl, ok := obj.Decl.(*ast.ValueSpec); ok { return fmt.Sprintf("const %s %v = %s", obj.Name, prettyType{typ}, pretty{decl.Values[0]}) } return fmt.Sprintf("const %s %v", obj.Name, prettyType{typ}) case ast.Lbl: return fmt.Sprintf("label %s", obj.Name) case ast.Typ: typ = typ.Underlying(false, types.DefaultImporter) return fmt.Sprintf("type %s %v", obj.Name, prettyType{typ}) } return fmt.Sprintf("unknown %s %v", obj.Name, typ.Kind) }