I have no special knowledge of the code, but it looks like the reason is so that ServeMux.es, which is a []muxEntry, can be searched. See the latter half of `func (mux *ServeMux) match() <https://golang.org/src/net/http/server.go?h=ServeMux#L2279>` for example.
That said, it may be possible to have ServeMux.m be a `map[string]Handler` instead. If so, then my guess is that ServeMux.m and ServeMux.es both use muxEntry just to slightly simplify the code. The assumption would be that the memory cost is negligible. But I could be wrong, and maybe there is a case where ServeMux.m must be a muxEntry, and not just a Handler. On Monday, December 14, 2020 at 8:52:27 PM UTC-5 amits...@gmail.com wrote: > Hi all, the ServerMux struct is currently defined as: > > type ServeMux struct { > // other fields > m map[string]muxEntry > } > > > The muxEntry is then defined as: > > type muxEntry struct { > h Handler > pattern string > } > > Is there any reason for also storing the pattern in the muxEntry since it > *seems* like the lookup only happens using the key in the map of ServeMux? > > Thanks for any insights. > > > Best Regards, > Amit > > > -- 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/42544681-9f1f-4e76-a4da-52330ee1628en%40googlegroups.com.