Selectors
…
- For a value
xof typeIwhereIis an interface type,x.fdenotes the actual method with namefof the dynamic value ofx. If there is no method with namefin the method set ofI, the selector expression is illegal.
type I interface {
Greet()
}
type Person struct {
Name string
}
func (p *Person) Greet() {
fmt.Printf("Hello, %s", p.Name)
}
var I x
x = &Person{}
x.Greet // denotes the actual Greet method Person, which is the dynamic value of x
Quotes from The Go Programming Language Specification Version of August 2, 2023