Skip to content

Instantly share code, notes, and snippets.

@yukihir0
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save yukihir0/f11576dd01256b744609 to your computer and use it in GitHub Desktop.

Select an option

Save yukihir0/f11576dd01256b744609 to your computer and use it in GitHub Desktop.
GolangでネストしたMapを使う。
package main
import (
"fmt"
)
func main() {
data := map[string]map[string]int{
"first": map[string]int{},
}
data["first"]["one"] = 1
data["first"]["two"] = 2
fmt.Println(data)
// -> map[first:map[two:2 one:1]]
// bad
// data["second"]["one"] = 1
data["first"] = map[string]int{"three": 3}
fmt.Println(data)
// -> map[first:map[three:3]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment