package main
import "fmt"
func main() {
// Here is an array of 8 integers. Subscripts are 0 to 7.
var vals [8]int
// Let's fill it with some data. Happily, and unlike C, the
// array can tell us how big it is.
for i := 0 ; i < len(vals); i++ {
vals[i] = 2*i + 1
}
// The built-in range function helps iterate through arrays.
fmt.Println("The integer array is:")
for i, value := range vals {
fmt.Printf(" %d => %d\n", i, value)
}
// Arrays can be created an initialized with a list, similar to
// Java and C.
mike := [6]string{"This","is","an","array","of","string"}
// If we don't need the index (or the value), we can replace it
// with underscore to discard it.
fmt.Print("The string array is: ")
for _, value := range mike {
fmt.Print(value+" ")
}
fmt.Println()
}