Standard library / sync

sync.Map.Clear()

Remove all entries (Go 1.23+). Expected stdout: 'false\n'.

Formal Syntax & Structure

go syntaxgo
func (m *Map) Clear()

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync")
func main() { var m sync.Map; m.Store("a", 1); m.Clear(); _, ok := m.Load("a"); fmt.Println(ok) }
Go Reference