Slice merge in golang recommendation

Viewed 3784

Is there a way to make this golang code shorter?

func MergeSlices(s1 []float32, s2 []int32) []int {
    var slice []int
    for i := range s1 {
        slice = append(slice, int(s1[i]))
    }
    for i := range s2 {
        slice = append(slice, int(s2[i]))
    }
    return slice
}
4 Answers
var s1 []int
var s2 []int

newSlice = append(s1, s2...)
Related