Type semantics
Method sets
For a simple defined nonpointer, noninterface type T, its method set contains value-receiver methods; *T also has pointer-receiver methods. Embedding may promote methods. Implicit addressing at a call does not add methods to T’s set. Example output: '5'.
Formal Syntax & Structure
go syntaxgo
func (t T) Read(); func (t *T) Change()Working Example
Example Snippetgo
package main
import "fmt"
type Counter int
func (c *Counter) Inc() { (*c)++ }func main() { v := Counter(3) v.Inc() var x interface{ Inc() } = &v x.Inc() fmt.Println(v)}