The golang’s function is a code block like C’s, but it can also be assigned to a variable as its other types.
If you are not familiar with the function, Codewalk: First-Class Functions in Go should be a good starting point for you. Already known it? Let’s go on.
First of all, look at this PHP codes:
function foobar() { echo "Hello Golang\n"; } $funcs = array( "foobar" => "foobar", "hello" => "foobar", ); $funcs["foobar"](); $funcs["hello"]();
It will print:
mikespook@mikespook-laptop:~/Desktop$ php foobar.php Hello Golang Hello Golang