29 lines
436 B
Go
29 lines
436 B
Go
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)
|
|
}
|
|
}
|