aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-06-24 16:34:12 +0200
committerRon Evans <[email protected]>2024-08-17 11:49:14 +0200
commit250426c1e525f4600db9ff2aa6ef0d2e791b98e8 (patch)
treeb2649f7a589bf80b82cc12cdebec912d59c091cb /src
parente300e90a637a6107fb18389fb4091c12fd3054b2 (diff)
downloadtinygo-250426c1e525f4600db9ff2aa6ef0d2e791b98e8.tar.gz
tinygo-250426c1e525f4600db9ff2aa6ef0d2e791b98e8.zip
sync: add Map.Clear()
This was added in Go 1.23 and is needed for the net/mail package.
Diffstat (limited to 'src')
-rw-r--r--src/sync/map_go123.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sync/map_go123.go b/src/sync/map_go123.go
new file mode 100644
index 000000000..b7bd61e10
--- /dev/null
+++ b/src/sync/map_go123.go
@@ -0,0 +1,13 @@
+//go:build go1.23
+
+package sync
+
+// Go 1.23 added the Clear() method. The clear() function is added in Go 1.21,
+// so this method can be moved to map.go once we drop support for Go 1.20 and
+// below.
+
+func (m *Map) Clear() {
+ m.lock.Lock()
+ defer m.lock.Unlock()
+ clear(m.m)
+}