[go-nuts] Re: %v for []string{} and []string{""}

2021-03-18 Thread 'Kevin Chowski' via golang-nuts
The "%#v" print verb is intended to be used for unambiguous printing of a type, but that means it will have a prefix of `[]string` in order to ensure the type is unambiguous. I personally use %q a lot any time I know I have a string (or set of strings) which might be ambiguous in some way, but I

[go-nuts] Re: %v for []string{} and []string{""}

2021-03-18 Thread Brian Candler
Sure. I don't have a problem with nil slice and empty slice showing the same, because in all important ways they behave the same - i.e. they have len() of 0, you can append() to them, etc. The only behavioural difference I can think of is if you explicitly test "foo == nil". However, a slice

[go-nuts] Re: %v for []string{} and []string{""}

2021-03-17 Thread tapi...@gmail.com
Printing a nil slice also get the same output []. I remembered Rob Pike ever said in an issue thread that this can't be changed now for compatibility reason. On Monday, March 15, 2021 at 8:18:46 AM UTC-4 Brian Candler wrote: > I was slightly surprised to discover that the Print() output for an