Skip to content

Instantly share code, notes, and snippets.

@pablocattaneo
Created January 26, 2026 14:00
Show Gist options
  • Select an option

  • Save pablocattaneo/fe1361933e53d5e8734182e2a70a3405 to your computer and use it in GitHub Desktop.

Select an option

Save pablocattaneo/fe1361933e53d5e8734182e2a70a3405 to your computer and use it in GitHub Desktop.
myMap := make(map[string]int)
myMap["key1"] = 15
myMap["key2"] = 100
myMap["key3"] = 7
myMap["key4"] = 23
value, exists := myMap["key1"]
fmt.Println("Value for key1:", value, "Exists:", exists) //Value for key1: 15 Exists: true
valueOfKey10, existsKey10 := myMap["key10"]
fmt.Println("Value for key10:", valueOfKey10, "Exists:", existsKey10) // Value for key10: 0 Exists: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment