learn_go/map/main.go

29 lines
436 B
Go
Raw Permalink Normal View History

2022-02-12 00:22:02 +01:00
package main
import "fmt"
func main() {
// Method 1
//var colors map[string]string
// Method2
//colors := make(map[string]string)
colors := map[string]string{
"red": "#ff0000",
"green": "#gr0000",
"white": "#fffff",
}
//colors["white"] = "#ffffff"
//delete(colors, "white")
printMap(colors)
}
func printMap(c map[string]string) {
for color, hex := range c {
fmt.Println("Hex code for", color, "is", hex)
}
}