Open1

go slice empty nil

noz3noz3
type A struct {
    id   int64
    name string
}

// 1. Nil slice - no memory allocated
var arrays []*A      // == nil, len=0, cap=0

// 2. Empty slice - memory allocated
arrays := []*A{}     // != nil, len=0, cap=0

// 3. Initialized slice - memory allocated with capacity
arrays := make([]*A, 0, 10) // != nil, len=0, cap=10