Here, We will learn how to get minimum between two numbers in go. We can get it by using Min() function in math package in go golang.
Function prototype:
func Min(x, y float64) float64
Input parameters: x and y as float64 type
Return value:
Min() function in math package returns
minimum between two numbers
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no := math.Min(1.2, 3)
fmt.Println(no)
no = math.Min(2.3, 1)
fmt.Println(no)
no = math.Min(0.0, -3)
fmt.Println(no)
no = math.Min(-2.9, 10)
fmt.Println(no)
}
Output:
1.2
1
-3
-2.9
To learn more about golang, Please refer given below link:
https://www.techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/