Function semantics

Multiple result values

Multiple results are separate values, not a tuple type. Use matching assignment targets or pass all results directly as the sole argument list to a compatible call. Example output: '3 2'.

Formal Syntax & Structure

go syntaxgo
func f() (T, U); a, b := f()

Working Example

Example Snippetgo
package main
import "fmt"
func divide(n, d int) (int, int) { return n / d, n % d }func main() {  q, r := divide(17, 5)  fmt.Println(q, r)}
Go Reference