arrays
Fixed Length
Creation
Usage
Slice
Abstraction on top of array, has make capacity
Struct with ptr passed by value, so array reference passed by ref and length pass by val
Can use base array stuff
Initialization
Make ([type], [initial size], [capacity or inital size]): allocate & initialize to null value for the type(int=0)
New: allocates but !initialize mem, if you try to set val you fail
W/out number its a slice
var x []float64
//length 0numbers := make([]int, 5, 5)
var colors = []string{"Red", "Green", "Blue"}
Usage
Append creates a new slice if needed
colors = append(colors, "Purple")
sort.Ints(numbers)
withsort
packagecopy(newSlice, slice)
Last updated