Type system

Go function types

Describes parameter and result types. Function values may be nil and can only be compared with nil, not each other. Example output: '12'.

Formal Syntax & Structure

go syntaxgo
func(T) R

Working Example

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