Skip to content

expvar: add Delete function #73815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/next/73814.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg expvar, func Delete(string) #73814
2 changes: 2 additions & 0 deletions doc/next/6-stdlib/99-minor/expvar/73814.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- go.dev/issue/73814 -->
[Delete] has been added to remove named exported variables added by [Publish].
5 changes: 5 additions & 0 deletions src/expvar/expvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ func Publish(name string, v Var) {
slices.Sort(vars.keys)
}

// Delete removes a named exported variable.
func Delete(name string) {
vars.Delete(name)
}

// Get retrieves a named exported variable. It returns nil if the name has
// not been registered.
func Get(name string) Var {
Expand Down