Skip to content

Instantly share code, notes, and snippets.

@victorsteven
Last active June 24, 2019 14:23
Show Gist options
  • Select an option

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

Select an option

Save victorsteven/41a0d976da50f12001a3166aa14dbde0 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
//map with a key of string and value of a slice of string:
nameAndHobby := map[string][]string{
"Steven": []string{"Basket Ball", "Table Tennis", "Coding"},
"Nnamdi": []string{"Sleeping", "Watching Movie", "Eating"},
}
//We can add someone else with their hobby:
nameAndHobby["Timi"] = []string{"Watching Cartoon",
"Dreaming",
"Laughing",
"Lazing around",
}
//We can delete from the map:
delete(nameAndHobby, "Steven")
for i, v := range nameAndHobby {
fmt.Printf("%v likes \n", i)
for j, value := range v {
fmt.Printf("\t%v %v\n", j, value)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment