Named result parameters / values in Go
In this example
func WebCmd(cmd string) (restCall string) {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.
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
}
Comments
Post a Comment