Exercises
- Browse the Go documentation site: https://golang.org/doc/.
- Write a Go program that keeps reading integers until you give the number 0 as input, then it prints the minimum and maximum integer in the input.
- Write the same Go program as before, but this time, you will get your input using command-line arguments. Which version do you think is better? Why?
- Write a Go program that supports two command-line options (
-i
and-k
) in random order using if statements. Now change your program to support three command-line arguments. As you will see, the complexity of the latter program is just too much to handle using if statements. - If the indices of a map were natural numbers, are there any cases that it would be wise and efficient to use a map instead of an array?
- Try to put the functionality of
array2map.go
into a separate function. - Try to develop your own random number generator in Go that will still use the current time as a seed but not the
math/rand
package. - Learn how to create a slice from...