去一维数组结合二维数组与追加

I have two one dimensional array and I want to combine the two single arrays into one multi dimensional array with append.

How would this be done for the fastest in go?

val time []int64
val value []float64

val 2darray [][]int64, float64

Would append be the best way to do this in go?

Here's an example of how it can be done:

package main

import (
    "fmt"
)

type TimeAndValue struct {
    time  int64
    value float64
}

func main() {
    times := []int64{0, 1, 2, 3, 4}
    values := []float64{1.23, 2.34, 3.45, 4.56, 5.67}

    timesAndValues := zip(times, values)

    fmt.Println(timesAndValues)
}

func zip(ts []int64, vs []float64) []TimeAndValue {
    if len(ts) != len(vs) {
        panic("not same length")
    }

    var res []TimeAndValue
    for i, t := range ts {
        res = append(res, TimeAndValue{time: t, value: vs[i]})
    }

    return res
}

https://play.golang.org/p/1OWJ1HG1XL