I was learning about pointers in Go. And managed to write something like:
func hello(){
fmt.Println(\"Hello World\")
}
func main(){
pfunc := hel
You could do it like this:
package main
import "fmt"
func hello(){
fmt.Println("Hello World")
}
func main(){
var pfunc func()
pfunc = hello //pfunc is a pointer to the function "hello"
pfunc()
}
If your function has arguments and e.g. a return value, it would look like:
func hello(name string) int{
fmt.Println("Hello %s", name)
return 0
}
and the variable would look like:
var pfunc func(string)int