Answers for "golang map type keys"

Go
6

golang map has key

if val, ok := dict["foo"]; ok {
    //do something here
}
Posted by: Guest on February-23-2020
1

golang map

//map in go is a built in type implementaiton of has table
//create an empty map
myMap := make(map[string]string)
//insert key-value pair in map
myMap["key"] = "value"
//read from map
value, ok := myMap["key"]
//delete from map
delete(myMap, "key")
Posted by: Guest on September-07-2021

Browse Popular Code Answers by Language