How to Handle Multiple Return Values in Go

Return multiple values in Go by listing them in parentheses and assigning them to multiple variables or ignoring extras with the blank identifier.

Go functions return multiple values by listing them in parentheses after the function name, and you capture them by assigning to multiple variables on the left side of the assignment.

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

quotient, remainder := divide(10, 3)

If you only need one value, use the blank identifier _ to ignore the rest.