Home > other >  Golang call methods both use difference
Golang call methods both use difference

Time:01-08

New (controller. ConfigController). The Router, the Router)
Controller. ConfigController {}. The Router (Router)
What is the difference between the two, after using the new method is called again, and this have what differentiation

CodePudding user response:

New is pointer type, that is, new (controller. ConfigController) equivalent to & amp; controller. ConfigController {}
And the controller. ConfigController {} simply struct type
In this case you use no difference, but in some method calls, parameter type is a pointer type or structure required, have distinction,
  • Related