Search code examples
godefault-valuefunction-calldefault-arguments

Default value in Go's method


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