Standard library / sync

sync.Map.Delete()

Remove an entry if present. Expected stdout: 'false\n'.

Formal Syntax & Structure

go syntaxgo
func (m *Map) Delete(key any)

Parameters & Attributes

NameTypeDescription
keyanyComparable map key, or a package-specific comparable context key.

Working Example

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