Reputation: 22254
I'm trying to learn the basics of Go by tweaking examples as I go along the tutorial located here:
Here's a small function I wrote that just turns ever character to all caps.
package main
import (
"fmt"
"strings"
)
func capitalize(name string) {
name = strings.ToTitle(name)
return
}
func main() {
test := "Sergio"
fmt.Println(capitalize(test))
}
I'm getting this exception:
prog.go:15: capitalize(test) used as value
Any glaring mistakes?
Upvotes: 4
Views: 11738
Reputation: 91243
You are missing the return type for capitalize()
:
package main
import (
"fmt"
"strings"
)
func capitalize(name string) string {
return strings.ToTitle(name)
}
func main() {
test := "Sergio"
fmt.Println(capitalize(test))
}
Output:
SERGIO
Upvotes: 12