* fix: finish support of type assertions which was incomplete TypeAssert was optimistically returning ok without verifying that value could be converted to the required interface (in case of type assert of an interface type), or not checking the type in all conditions. There is now a working implements method for itype. Fixes #640. * style: appease lint * fix: remove useless code block * doc: improve comments * avoid test conflict
24 lines
294 B
Go
24 lines
294 B
Go
package main
|
|
|
|
type Root struct {
|
|
Name string
|
|
}
|
|
|
|
type One struct {
|
|
Root
|
|
}
|
|
|
|
type Hi interface {
|
|
Hello() string
|
|
}
|
|
|
|
func (r *Root) Hello() string { return "Hello " + r.Name }
|
|
|
|
func main() {
|
|
var one interface{} = &One{Root{Name: "test2"}}
|
|
println(one.(Hi).Hello())
|
|
}
|
|
|
|
// Output:
|
|
// Hello test2
|