Expression

Method expressions

A method expression selects a method from a type and exposes the receiver as the first function parameter. The method must belong to that type’s method set; no receiver is bound. Example output: '7'.

Formal Syntax & Structure

go syntaxgo
f := T.Method; f(receiver, args...)

Working Example

Example Snippetgo
package main
import "fmt"
type Count int
func (c Count) Read() int { return int(c) }func main() {  f := Count.Read  fmt.Println(f(Count(7)))}
Go Reference