Passing a function as a parameter - Callback function
As it is right now, the run
function can only accept callback functions without any parameter
package main
import (
"fmt"
)
func main() {
run(hello)
run(world)
}
func hello() {
fmt.Println("Hello")
}
func world() {
fmt.Println("World!")
}
func run(f func()) {
f()
}