Skip to content

Instantly share code, notes, and snippets.

@jjuliano
Last active December 16, 2019 11:07
Show Gist options
  • Save jjuliano/ea11c3d80f481d53f95930d7b3931b77 to your computer and use it in GitHub Desktop.
Save jjuliano/ea11c3d80f481d53f95930d7b3931b77 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type produce struct {
name string
flavour string
kind string
}
func main() {
items := map[string]produce{
"item1": produce{
name: "apple",
flavour: "It's a little sour and bitter, but mostly sweet, not at all salty, very juicy in general.",
kind: "fruit",
},
}
fruits := basket(items)
fmt.Println("Name: ", fruits["item1"].name)
fmt.Println("Flavour: ", fruits["item1"].flavour)
fmt.Println("Kind: ", fruits["item1"].kind)
}
func basket(options ...map[string]produce) map[string]produce {
var items map[string]produce
items = make(map[string]produce)
for _, hash := range options {
for key, value := range hash {
items[key] = value
}
}
return items
}
// Name: apple
// Flavour: It's a little sour and bitter, but mostly sweet, not at all salty, very juicy in general.
// Kind: fruit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment