remove a key and value from a map with a key of type int in go

main.go
// create a map with int key and string value
m := map[int]string{
    1: "one",
    2: "two",
    3: "three",
}

// remove key 2 from the map
delete(m, 2)
156 chars
10 lines

This code creates a map with int keys and string values, then removes the key-value pair with key 2 from the map using the built-in delete function in Go. The delete function takes two arguments: the map and the key to be deleted. In this example, it removes the entry with key 2 from the map m.

gistlibby LogSnag