Create List
Examples in
Go
package main
import (
"fmt"
)
func main() {
// Create a nil slice.
var a []int
fmt.Println(a)
// Create slice literal.
b := []int{1, 2, 3}
fmt.Println(b)
// Create slice using make.
c := make([]int, 5)
fmt.Println(c)
// Create slice from nil.
d := append([]int(nil), 1, 2, 3)
fmt.Println(d)
}
Last Run
:
[]
[1 2 3]
[0 0 0 0 0]
[1 2 3]