package main import "fmt" func main() { a := []int{1, 2, 3} a = a[:0] fmt.Println(a, len(a), cap(a)) } // [] 0 3 package main import "fmt" func main() { a := []int{1, 2, 3} a = nil fmt.Println(a, len(a), cap(a)) } // [] 0 0