This is a creation in Article, where the information may have evolved or changed.
Func main () {arr := [10]int {1,2,3,4,5,6,7,8,9,10}var slice1 []int = arr[:5] //the first 5 slice2 := arr[5:]//of the array to take the array after 5 slice3 := make ([]int, 5)// Make a slice, initialize the top 5 to 0 myslice2 := make ([]int, 5, 10) // make a slice, initialize the first 5 to 0, the initial capacity is 10myslice3 : = []int{1,2,3,4} // Direct Assignment // cap: capacity len length fmt. Println (Cap (MYSLICE2), len (MYSLICE2)) s1 := []int{1,2,3}s2 := make ([]int, 5) S2 = append (s2, 5,4,7) // Append Data s2 = append (s2, s1 ...) // Append a slice copy (s1, s2) // copy for _, res := range slice1 {fmt. Println (res)}fmt. PRINTLN ("---") for _, res := range slice2 {fmt. Println (res)}fmt. PRINTLN ("---") for _, res := range slice3 {fmt. Println (RES)}}