diff --git a/17-maps/_experimental/main.go b/17-maps/_experimental/main.go new file mode 100644 index 0000000..12f580d --- /dev/null +++ b/17-maps/_experimental/main.go @@ -0,0 +1,36 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +// why maps instead of keyed arrays etc? +// 120k elements! + +package main + +import ( + "fmt" + "os" + "unicode/utf8" +) + +func main() { + args := os.Args[1:] + if len(args) != 1 { + fmt.Println("[emoji]") + return + } + + moods := [...]string{ + '😊': "a happy", + '😟': "a worried", + '😎': "an awesome", + '😞': "a sad", + '😩': "a crying", + } + + emoji, _ := utf8.DecodeRune([]byte(args[0])) + fmt.Printf("%s is %s emoji\n", args[0], moods[emoji]) +}