Essential Go Functions  Suggest an edit


A function can optionally declare a set of parameters:

func SayHelloToMe(firstName, lastName string, age int) {
	fmt.Printf("Hello, %s %s!\n", firstName, lastName)
	fmt.Printf("You are %d\n", age)

func main() {
	SayHelloToMe("John", "Doe", 35)
Hello, John Doe!
You are 35

Type for firstName is omitted because it is identical to lastName.

  ↑ ↓ to navigate     ↵ to select     Esc to close