While array in Go is fixed size, slice on the other hand is not. You declare a variable without specifying the size, and if new element is needed use the append()
function to add element to each index.
package main import "fmt" func main() { // slice does not require the need to declare the size // this is more flexible. var slices [] int for i:=0; i<10; i++ { // new element is added using the append() function. slices = append(slices, i) fmt.Printf("%d\n", slices[i]) } }