4 ms·
Good point - when developing the package, I was referencing these [1][2] documents which showed the use of NewObject() instead of New(). I figured since I provi
by jwcrux 13y ago
Good point - when developing the package, I was referencing these [1][2] documents which showed the use of NewObject() instead of New(). I figured since I provide more than one possible struct (both Email and Attachment), the use of NewEmail would provide consistency.
However, now that you mention it, I suppose it wouldn't have hurt, and the meaning would have been fairly clear. Oh well - live and learn, at this point, I'm doing my best not to break backwards compatibility if I don't have to.
Thanks for the heads up!
[1] http://golang.org/doc/effective_go.html#composite_literals http://golang.org/doc/effective_go.html#composite_literals
[2] https://sites.google.com/site/gopatterns/object-oriented/constructors https://sites.google.com/site/gopatterns/object-oriented/con...
- dkuntz2 13y agoLike ihsw said, in Go you probably should leave it as `NewEmail` because `New` is ambiguous.
- DrJokepu 13y agoIf your package exports a single type only, New is more appropriate, if it exports multiple types, you should use NewObject: http://golang.org/doc/effective_go.html#names http://golang.org/doc/effective_go.html#names
- scott_s 13y agoStuart Feldman, from "The Art of Unix Programming", on why makefiles must use tabs: "Why the tab in column 1? Yacc was new, Lex was brand new. I hadn't tried either, so I figured this would be a good excuse to learn. After getting myself snarled up with my first stab at Lex, I just did something simple with the pattern newline-tab. It worked, it stayed. And then a few weeks later I had a user population of about a dozen, most of them friends, and I didn't want to screw up my embedded base. The rest, sadly, is history."