Can you do anything in Go with a *func()
?
var f func() = foo // works
var g *func() // works
g = foo // fails `cannot use foo (type func()) as type *func() in assignment` as expected
g = &foo // fails too `cannot take the address of foo`
You can't take the address of a function definition, you can take the address of a function value. This works:
g := &f
Playground example: https://play.golang.org/p/BokYCrVmV_p
You can pass it around and set it:
func a(f *func()) {
*f = foo
}
func main() {
var f func()
a(&f)
f()
}