Application
Create new folder named src. In src folder, create new file named main.go as below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
package main import "fmt" func main() { var a = [5]int{11, -4, 7, 8, -10} min := findMin(a) fmt.Println("Min: ", min) } func findMin(a [5]int) (min int) { min = a[0] for _, value := range a { if value < min { min = value } } return min } |
Output:
1 2 3 4 5 |
Min: -10 Program exited. |