I'm a complete beginner to the Go programming language, and I'm trying to define the parameter types of a Go function called addStuff
that simply adds two integers and returns their sum, but I see the following error when I try to compile the function:
prog.go:6: undefined: a
prog.go:6: undefined: b
prog.go:7: undefined: a
prog.go:7: undefined: b
prog.go:7: too many arguments to return
prog.go:11: addStuff(4, 5) used as value
Here's the code that produced this compiler error:
package main
import "fmt"
import "strconv"
func addStuff(a, b){
return a+b
}
func main() {
fmt.Println("Hello," + strconv.Itoa(addStuff(4,5)))
}
What am I doing wrong here, and what is the correct way to set the types of parameters in Go?