If you would like to create an empty slice in Go, then you can do the following:

Option 1 – Initialize an Empty Slice in Go

1
2
3
4
5
6
7
8
package main

import "fmt"

func main() {
    b := []string{}
    fmt.Println(b == nil)
}

Option 2 – Using make()

1
2
3
4
5
6
7
8
package main

import "fmt"

func main() {
    c := make([]string, 0)
    fmt.Println(c == nil)
}