Avoid to test directly for a type category, as it may give wrong results for aliased types, where the interesting category remains masked. Instead, use some property helpers, such as isFuncSrc, isPtrSrc and isInterfaceSrc to check if a type is of source function, source pointer or source interface respectively (versus runtime defined function, pointer or interface). Fixes #1068.
20 lines
178 B
Go
20 lines
178 B
Go
package main
|
|
|
|
type I interface {
|
|
Hello()
|
|
}
|
|
|
|
type T struct{}
|
|
|
|
func (t T) Hello() { println("hello") }
|
|
|
|
type I2 I
|
|
|
|
func main() {
|
|
var i I2 = T{}
|
|
i.Hello()
|
|
}
|
|
|
|
// Output:
|
|
// hello
|