Quick actions

cmd+k|ctrl+k

Navigation

Languages

Slices / Create a slice / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-04-18T17:15:25Z

Updated

2019-04-18T17:15:25Z

package main

import (
	"fmt"
)

func main() {
	var nilSlice []bool
	empty1 := []bool{}
	empty2 := make([]bool, 0)
	fmt.Printf("nilSlice is %#v\n", nilSlice)
	// empty slice is different than nil slice
	fmt.Printf("empty1 is %#v\n", empty1)
	fmt.Printf("empty2 is %#v\n", empty2)
}
INFO