Use ... to let Go count the elements:
nums := [...]int{1, 2, 3, 4, 5}
Go sets the array size based on the number of values you provide. This is convenient but the result is still a fixed-size array. The type is []int, not a slice.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Let Go count
Use ... to let Go count the elements:
nums := [...]int{1, 2, 3, 4, 5}
Go sets the array size based on the number of values you provide. This is convenient but the result is still a fixed-size array. The type is []int, not a slice.