I\'m curious if this is possible in Go. I have a type with multiple methods. Is it possible to have a function which takes a method argument and then call it for the type?>
You could also use the “method values” option listed by @icza with different receivers.
package main
import "fmt"
type Foo int
type Goo int
func (f Foo) A() { fmt.Println("A") }
func (f Foo) B() { fmt.Println("B") }
func (g Goo) A() { fmt.Println("A") }
func main() {
//Method values with receiver f
var f Foo
bar2 := func(m func()) { m() }
bar2(f.A) //A
bar2(f.B) //B
//Method values with receivers f and g
var g Goo
bar2(f.A) //A
bar2(g.A) //A
}