Parameters

Download go eBook

Example

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", age)
}

Notice that the type for firstName is omitted because it is identical to lastName.

Stats

Contributors: 1
2016-04-07
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook