2011-05-14

Named result parameters / values in Go


In this example
func WebCmd(cmd string) (restCall string) {
m := map[string]string{
"c":   "https://mail.google.com/mail/?shva=1#compose",
"t":   "http://twitter.com",
"lox": "https://github.com/loxal/Lox",
}
restCall = m[cmd]
return
}
restCall is the named return parameter of type string and cmd is the unnamed parameter required to call theWebCmd function. Within the WebCmd function the string value of m[cmd] is assigned to the restCall variable which is returned by the WebCmd function.