How to refer to an unnamed function argument in go? -


the name of function parameter in go optional. meaning following legal

func hello(string) {      fmt.println("hello") }  func main() {     hello("there") } 

(go playground link)

how can refer 1. argument (declared type of string) argument in foo() function ?

the use of unnamed parameters when have define function specific signature. instance, have example in 1 of projects:

type export struct {     f func(time.time, time.time, string) (interface{}, error)     folder    string } 

and can use both of these functions in it:

func exportevents(from, time.time, name string) (interface{}, error) func exportcontacts(from, time.time, _ string) (interface{}, error) 

even though in case of exportcontacts, not use string parameter. in fact, without naming parameter, have no way of using in function.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

ios - Change Storyboard View using Seague -

verilog - Systemverilog dynamic casting issues -