3 ms·
Some people do exactly that and avoid methods altogether. It's perfectly valid to use: func sayHello(f *Foo) { ... } One major difference between function
by andreygrehov 6y ago
Some people do exactly that and avoid methods altogether. It's perfectly valid to use:
func sayHello(f *Foo) { ... }
One major difference between functions and methods in Go is you can have multiple methods with same name while no two functions with the same name can be defined in a package. Also, there is a subtle difference, which is more subjective, between user.IsActive() and IsActive(user). The former explicitly implies that you operate on a user, whereas the later one isn't that obvious, like what if I do IsActive(group), is that also allowed? I like that Go is not trying to be super flexible, but it also nicely holds a niche of a slightly improved (in terms of usability) C.