Fukntia is the ultimate value in Go. You can make this name a field, and assign it a value:
package main type Typ struct { foo func () } func main() { t := Typ{} t.foo = func () { println("first implementation") } t.foo() t.foo = func () { println("second implementation") } t.foo() }
will issue:
first implementation second implementation
UPD : If you want exactly the method, then you can call a variable field in the method.
package main type A struct { } var globalFoo = func () string { return "first" } func (a A) getName() string { return globalFoo() } func main() { a := A{} println(a.getName()) globalFoo = func () string { return "second" } println(a.getName()) }
But the fact that you want this is already alarming.