Is “net/http”'s use of global variables considered a good practice in golang?

前端 未结 2 538
星月不相逢
星月不相逢 2021-02-07 09:30

The golang package \"net/http\" uses the global variable DefaultServeMux to register handlers. Is this considered a good practice or even an golang idiom? Is it a global variabl

2条回答
  •  我寻月下人不归
    2021-02-07 10:24

    The globvar is, in this case, as safe and as good choice as the analogue seen in e.g package "log" is.

    IOW, claim 1 is as vague as it can get and claim 2 is constrained: sometime/somewhere true, otherwise false == doesn't hold in general even though used just like that.

提交回复
热议问题