Skip to content

Instantly share code, notes, and snippets.

@178inaba
Last active January 4, 2021 17:28
Show Gist options
  • Save 178inaba/3f31d15cb20b092e26a5076cef13fcd4 to your computer and use it in GitHub Desktop.
Save 178inaba/3f31d15cb20b092e26a5076cef13fcd4 to your computer and use it in GitHub Desktop.
Append map slice.
package main
import (
"fmt"
)
type foo struct {
i int
}
func main() {
m := map[int][]*foo{}
m[1] = append(m[1], &foo{i: 123})
m[1] = append(m[1], &foo{i: 456})
fmt.Println(m)
fmt.Println(m[1])
fmt.Println(m[1][0])
fmt.Println(m[1][1])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment