The first pair is used to receive a parameter that is treated in a special way. This is called method receiver. It is a very similar way as languages treat methods where there is an implicit parameter that is the object this
, but in the case of Go is received explicitly. Being separated it is easier for the compiler to identify the special condition. Thus the method is applied only to a specific type. This way you can call the function as a method, that is, you call the method according to the object in use. If you think about it it makes even more sense than in other languages because you treat in the definition the parameter that is special and in the place that it is used in the call, although the syntax gets a little weird.
The second pair is used to establish a tuple of parameters, equal to all languages.
The third pair is used to group the return type of the function that always comes after the name and parameters of the function. It is used because in the case the type consists of a pointer and has the parameter name, thus avoids ambiguity and ensures that it is one thing.
A tip for those who know C# and VB: That syntax is like a Extension method for the guy
FlowContext
, then you can callflowContext.newNextDataSet(p1, p2)
instead ofnewNextDataSet(flowContext, p1, p2)
.– Gabriel
Yeah, it’s good looking.
– Maniero