You just declared a global variable. the standard library does exactly that with http Client. I assume if it is in the std lib I don't see why you shouldn't do that yourself.
Le mercredi 3 août 2016 15:19:52 UTC+2, d a écrit : > > 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.