The package names blog post may be useful, though it does not provide specific guidance on singular vs plurals: https://blog.golang.org/package-names On Tue, Jul 12, 2016 at 10:40 AM Sam Whited <s...@samwhited.com> wrote:
> On Tue, Jul 12, 2016 at 9:19 AM, Rayland <guianul...@gmail.com> wrote: > > When does it make sense for a package to be named in plural? For example, > > I'm currently working on a MVC framework and for me it makes sense to > have a > > "controller" package as opposed to "controllers", but I saw that Beego > > prefers plural for the same case. > > Generally speaking, try to consider how your users will write things > that use your package and not what's actually in it. For instance, > which makes the better API: > > controller.New() > > or: > > controllers.NewController() > > The second is redundant, so I'd argue that the first one will look > better in your users code. However, given the example: > > byte.Split(b []byte) > > vs. > > bytes.Split(b []byte) > > the second may be more expected because you're operating on a collection. > > Of course, both of these are just my opinion, but it's just to > illustrate how I generally think about picking a name. Instead of > "what will my code in the package look like" think "what will my users > write using this package?" > > —Sam > > -- > 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. > -- 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.