Hi all, just saw a piece of software that make large use of methods defined
on (basically) empty structs as a namespacing hack.
Example:
type Foo struct {
}
func NewFoo() Foo {
return Foo{}
}
var (
foo = NewFoo()
)
func (self Foo) Bar1 () {
}
func (self Foo) Bar2 () {
}
This way I can call bar1 and bar2 as if they were func exposed on the
"package" foo, like this:
foo.Bar1()
foo.Bar2()
I assumed that is bad practice. What do you think?
Thanks
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.