expvar: make it possible to remove memstat and cmdline defaults #29105
Labels
FeatureRequest
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
The
expvar
package contains aninit
function that registers thememstats
andcmdline
vars to thedebug/vars
http handler. The package does not provide a means to remove these defaults, forcing the consumer to deal with them. It would be nice if the user had a means to remove these defaults without resorting tounsafe
or forking the package.A benchmark I've added reveals a mild but unnecessary performance impact with the defaults (when the number of total expvar.Vars is expected to be small), but the real problem I think is aesthetic: My other vars have nothing to do with memory usage or the command line, so the memory profile is intrusive to the application.
We also can't use
memstats
andcmdline
as named for our own purposes. This does not impact me personally.Interestingly, the package tests contain an unexported
RemoveAll
function. The recently-closed issue #27555 discusses it in detail, but does not mention the potential use for removing the default vars.The text was updated successfully, but these errors were encountered: