Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- // Create an anomynous struct.
- data := struct {
- m map[string]string
- order []string
- }{
- m: make(map[string]string),
- order: []string{},
- }
- // Insert several key/value pairs.
- data.m["Go"] = "Beego"
- data.order = append(data.order, "Go")
- data.m["Python"] = "Django"
- data.order = append(data.order, "Python")
- data.m["Ruby"] = "Rails"
- data.order = append(data.order, "Ruby")
- data.m["PHP"] = "Laravel"
- data.order = append(data.order, "PHP")
- // Iterate these key/value pairs with order.
- for _, e := range data.order {
- fmt.Println(fmt.Sprintf("%s: %s", e, data.m[e]))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement