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 }
Golang, array and slice
- Golang: Array
- Golang: Slice
- Golang: Slice of Slice
- Golang: Append to Slice
- Golang: Cut Slice (Delete Elements)
- Golang: Copy Slice
- Golang: Clear Slice
- Golang: Nested Slice
- Golang: Slice of Strings to String
- Golang: Iterate Slice
- Golang: Convert Value to String
- Golang: Convert Array to Slice
- Golang: Print Slice, Array