Skip to content

Instantly share code, notes, and snippets.

@victorsteven
Created June 24, 2019 13:27
Show Gist options
  • Select an option

  • Save victorsteven/ed4708f8aad65705b94557b4e9586176 to your computer and use it in GitHub Desktop.

Select an option

Save victorsteven/ed4708f8aad65705b94557b4e9586176 to your computer and use it in GitHub Desktop.
package main
import "fmt"
var nameAgeMap map[string]int
func main() {
nameAgeMap = map[string]int{
"James": 50,
"Ali": 39,
}
fmt.Println("Print the age of James: ", nameAgeMap["James"])
//We can range through the map and print each value:
for key, value := range nameAgeMap {
fmt.Printf("%v is %d years old\n", key, value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment