I see all the time a mix of package.New(), package.NewBlah() and
package.MyType() (eg. http://golang.org/pkg/os/exec/#Command), the mix of
which I find annoying because:

1) The .New() syntax doesn't make it obvious what type to return.

2) The .New() syntax requires a lot of heavy refactoring if you change the
api to add a new type (ie. New has to change to NewBlah())

3) Mixing it up with package.Blah() just confuses matters.

4) It seems terribly inconsistent to have 3 different 'standard' ways of
doing things.

I thought package.NewBlah() was the approved solution, but now I keep
stumbling into people doing it differently.

What's the go-centric way of doing this, and where is it documented?

(I saw http://golang.org/doc/effective_go.html#composite_literals, but it
isn't explicit there about naming)


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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
groupgolang-nuts @
postedFeb 25, '13 at 7:19a
activeFeb 25, '13 at 10:13p



site design / logo © 2021 Grokbase