Keyword
Go func keyword
Introduces a function declaration, function literal or function type. Declarations may have receivers for methods. Parameters and results describe a call contract, and omitted results mean no returned values. Example prints 12.
Formal Syntax & Structure
go syntaxgo
func Name(parameters) results { statements } | func(parameters) resultsWorking Example
Example Snippetgo
package main
import "fmt"
func triple(n int) int { return n * 3 }func main() { fmt.Println(triple(4))}