Is it all right os is better to use the another way?
// ===
type foo struct {
deb []string
warn []string
}
func newFoo() *foo {
return &foo{
make([]string, 0),
make([]string, 0),
}
}
func newFoo2() *foo {
return &foo{nil, nil}
}
func main() {
f1 := newFoo()
if len(f1.warn) != 0 {...}
f2 := newFoo2()
if f2.warn != nil {...}
}
// ===
Cheers
Dave
Sent from my iPhone
On Dec 18, 10:42 pm, Dave Cheney <d...@cheney.net> wrote:
> The zero value for a slice is nil, which has a len of zero. You can just return &foo{} or new(foo) depending on your preference.
>
> Cheers
>
> Dave
>
> Sent from my iPhone
>