Golang slice ergodic value problem

func MaxMin(position [][]float64) (max, min []float64) {

    for k, v := range position {
        if k == 0 {
            max = position[k]
            min = position[k]
            continue
        }
        if v[0] > max[0] {
            max[0] = v[0]
        }
        if v[1] > max[1] {
            max[1] = v[1]
        }
        if v[0] < min[0] {
            min[0] = v[0]
        }
        if v[1] < min[1] {
            min[1] = v[1]
        }
        fmt.Println(v)
    }
    return
}

the last return value is always the last bit of traversal, which should be affected by the characteristics of slice
optimize

Mar.12,2021

func MaxMin(position [][]float64) (max, min [2]float64) { // 

    for k, v := range position {
        if k == 0 {
            max = [2]float64{
                position[k][0],
                position[k][1],
            }
            min = [2]float64{
                position[k][0],
                position[k][1],
            }
            continue
        }
        if v[0] > max[0] {
            max[0] = v[0]
        }
        if v[1] > max[1] {
            max[1] = v[1]
        }
        if v[0] < min[0] {
            min[0] = v[0]
        }
        if v[1] < min[1] {
            min[1] = v[1]
        }
        fmt.Println(v)
    }
    return
}
Menu