-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
I tried to use noinit
with a []byte
slice, but the parser complained that field must be a pointer to have noinit
. It seems a bit unnecessary to insist on having a pointer to a slice, since a slice in itself can be nil
. Consider the following code:
package main
import "fmt"
type Lala struct {
Blah []byte
}
func main() {
lala := Lala{}
if lala.Blah == nil {
fmt.Println("Blah is nil")
}
lala.Blah = []byte{}
if lala.Blah != nil {
fmt.Println("Blah is not nil")
}
}
The result is:
Blah is nil
Blah is not nil
Metadata
Metadata
Assignees
Labels
No labels