On Sat, 13 Mar 2021, 15:05 Jan Mercl, <0xj...@gmail.com> wrote: > On Fri, Mar 12, 2021 at 1:24 AM Kevin Chadwick <m8il1i...@gmail.com> > wrote: > > > Why doesn't go auto init or make an empty map for a named return to > avoid the potential chance of a panic due to operating on a nil return? > > A non-zero value map value must be allocated. All well-known Go > compilers allocate maps in heap. Allocating automagically a map that > may end up never used is a waste of resources. >
Very little resources, unless the map is actually used and not for long. If you really need to control gos memory use, you need to preallocate arrays in a long standing manner anyway, not for maps though, as you can't delete without realloc. > -- 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/CANNfpqceqbKAAoSu2ukCiydsn5ZZaorEN7vt_%3D1-T-wh0NrrSA%40mail.gmail.com.