Skip to content

Commit 250426c

Browse files
aykevldeadprogram
authored andcommitted
sync: add Map.Clear()
This was added in Go 1.23 and is needed for the net/mail package.
1 parent e300e90 commit 250426c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/sync/map_go123.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build go1.23
2+
3+
package sync
4+
5+
// Go 1.23 added the Clear() method. The clear() function is added in Go 1.21,
6+
// so this method can be moved to map.go once we drop support for Go 1.20 and
7+
// below.
8+
9+
func (m *Map) Clear() {
10+
m.lock.Lock()
11+
defer m.lock.Unlock()
12+
clear(m.m)
13+
}

0 commit comments

Comments
 (0)