Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

36 lines
466 B

package main
import (
"fmt"
"os"
)
func getPassedArgs() string {
if len(os.Args) != 2 {
fmt.Printf("Exactly 1 argument is needed\n")
os.Exit(1)
}
return os.Args[1]
}
func main() {
m := map[string]string{
"305": "Sue",
"204": "Bob",
"631": "Jake",
"073": "Tracy",
}
key := getPassedArgs()
if name := m[key]; name != "" {
fmt.Println("Hi,", name)
} else {
fmt.Println(key, "not found")
os.Exit(1)
}
}