Built-in function
Go min()
Returns the least of one or more ordered arguments. It accepts individual arguments, not slice expansion. Strings compare by bytes; floating-point NaN propagates and negative zero wins over positive zero. Example prints 4. Requires Go 1.21.
Formal Syntax & Structure
go syntaxgo
min(x, y, ...)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | ordered value | First candidate. |
| others | compatible ordered values | Additional candidates. |
Return Value
common argument type or untyped constant
Least argument value.
Working Example
Example Snippetgo
package main
import "fmt"
func main() { fmt.Println(min(4, 11, 7))}