On Wed, 2023-01-25 at 07:21 -0800, Andrew Athan wrote:
> I'm sure I'm not the first to say this, but here's my +1:
>
> It seems wrong to me that golang displays nil-valued reference types
> as an empty instance of the type with no indication that the
> reference is nil.
>
> E.g.
> ```
> var m map[string]string
> fmt.Printf("%+v",m)
> ```
>
> displays as "map[]"
>
> I think it would be better to display something like "<nil>map[]",
> don't you?
>
> Motivation: While the nil map does act like a map[] for reads, it
> does not act like one for writes, and debugging via prints can
> therefore be confusing for new users.
>

For debugging, use %#v. https://go.dev/play/p/UlvaFg5Z_lB

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6e278c5a183432315bb86e19b4c4f7794c9b56ab.camel%40kortschak.io.

Reply via email to