slice1.goΒΆ

// slice1.go

// To run at the command line:
//    $ go run slice1.go

package main

import "fmt"

func main() {
    measurements := []float32{2.3, -0.1, 2, 2.001, 5.5, 5.22}

    fmt.Println("Method 1")
    for i := 0; i < len(measurements); i++ {
        fmt.Printf("measurements[%v] = %v\n", i, measurements[i])
    }

    fmt.Println("\nMethod 2")
    for i, m := range measurements {
        fmt.Printf("measurements[%v] = %v\n", i, m)
    }
}