HiveBrain v1.2.0
Get Started
← Back to all entries
patterngoCritical

Default value in Go's method

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
methodvaluedefault

Problem

Is there a way to specify default value in Go's function? I am trying to find this in the documentation but I can't find anything that specifies that this is even possible.

func SaySomething(i string = "Hello")(string){
...
}

Solution

No, the powers that be at Google chose not to support that.

https://groups.google.com/forum/#!topic/golang-nuts/-5MCaivW0qQ

Context

Stack Overflow Q#19612449, score: 191

Revisions (0)

No revisions yet.