Go Functions and Multiple Return Values

A Go function declares its parameter types after the names, and the form a, b int shares one type between both. A function can return several values, listed in parentheses, which Go programs use for results plus an error or, as here, a quotient plus a remainder.

Go
package main

import "fmt"

func divide(a, b int) (int, int) {
  return a / b, a % b
}

func main() {
  q, r := divide(17, 5)
  fmt.Println(q, r)
}
Read the full lesson