Function semantics

Function signatures

Parameter and result types in order, plus whether the function is variadic, determine function type identity; parameter and result names do not. Signature names help readers but are not named arguments. Example output: '12'.

Formal Syntax & Structure

go syntaxgo
func(a, b int) (int, bool)

Working Example

Example Snippetgo
package main
import "fmt"
func twice(n int) int { return 2 * n }func main() {  var f func(x int) int = twice  fmt.Println(f(6))}
Go Reference