if dumpType == nil { fmt.Printf("there is no type info for %v\n", i) return }
n := dumpType.NumMethod() if n == 0 { fmt.Printf("no methods found for '%T'\n", i) return }
fmt.Printf("Method set for '%T' (type %v):\n", i, dumpType) for i := 0; i < n; i++ { fmt.Printf("- %v\n", dumpType.Method(i).Name) } fmt.Println() }
// Output: // no methods found for 'int' // no methods found for '*int' // Method set for 'main.T' (type main.T): // - M1 // - M2 // // Method set for '*main.T' (type *main.T): // - M1 // - M2 // - M3 // - M4
i = p // i = t // cannot use t (type T) as type Interface in assignment: // T does not implement Interface (M2 method has pointer receiver) }
// Output: // there is no type info for <nil> // Method set for '*main.T' (type *main.T): // - M1 // - M2 // // Method set for 'main.T' (type main.T): // - M1