Slices and Arrays
Learn about slices and arrays in Go.
In Go, slices and arrays serve a similar purpose. They are declared nearly the same way:
Press + to interact
package mainimport "fmt"func main() {slice := []int{1, 2, 3}array := [3]int{1, 2, 3}// let the compiler work out array length// this will be an equivalent of [3]intarray2 := [...]int{1, 2, 3}fmt.Println(slice, array, array2)}
Slices feel like arrays with useful functionality on top. They use pointers to arrays internally in their implementation. Slices however are so much more convenient that arrays are rarely ...