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

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -