Array and slice data types

See “Slices: usage and internals”

var av = []int{1,5,2,3,7}

That is a slice, not an array.

A slice literal is declared just like an array literal, except you leave out the element count.

That explains why the sort function will modify the content of what is referenced by the slice.

As commented below by Kirk, sort.Ints will give you an error if you passed it an array instead of a slice.

func Ints(a []int)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)