Functions and Multiple Returns
Functions in Go are first-class citizens. They can return multiple values and be passed around as variables.
func add(a int, b int) int {
return a + b
}
Multiple return values:
func divide(a, b int) (int, int) {
return a / b, a % b
}
quotient, remainder := divide(10, 3)
Anonymous functions:
greet := func(name string) {
fmt.Println("Hello,", name)
}
greet("Go")