Golang: Convert Array to Slice
Convert Array to Slice
array[:]-
Return a Slice of array. The slice shares the array storage.
package main import "fmt" func main() { var arr = [2]int{3, 4} // create a slice var s = arr[:] // s is now of type slice of int fmt.Printf("%T\n", s) // []int }