Problem scenario
You want to pass parameters to a function and assign the returned value to a parameter using the Go programming language. What should you do?
Solution
Prerequisite
This assumes that you have installed Golang; if you need assistance with this, see this posting.
Procedures
1. Create a file called c.go with this as the content:
package main
import "fmt"
// Function that accepts parameters and returns an integer value:
func multiply(x int, y int) int {
total := 0
total = x * y
return total
}
func main() {
// Pass integers for an example
newtotal := multiply(100, 50)
fmt.Println(newtotal)
}
2. Run it like this: go run c.go