project-layout icon indicating copy to clipboard operation
project-layout copied to clipboard

Examples, singular or plural?

Open nleiva opened this issue 6 years ago • 4 comments

The examples folder seems to conflict with: Use singular form for collection repo/folder name. Thoughts?

nleiva avatar May 31 '18 22:05 nleiva

You are absolutely right! However, even the Go creators deviate from these guidelines. The 'errors', 'strings' and 'bytes' packages are some of those examples.

Either way, it'll be good to add a few references around naming:

  • https://github.com/golang/go/wiki/CodeReviewComments
  • https://blog.golang.org/package-names
  • https://golang.org/doc/effective_go.html#names

kcq avatar Jun 02 '18 04:06 kcq

Look at comment-2. example(s) could be a collection of them (as in packer), unlike errors, strings, and bytes. The encoding example is an excellent reference (encoding/json, encoding/xml, encoding/gob).

I agree people deviate from this one. Just wondering what we would consider as best practice.

nleiva avatar Jun 02 '18 16:06 nleiva

If it's not a package name/directory it's ok to deviate from that recommendation/guideline. The examples directory falls into this category :-) Ultimately it's up to you to decide what makes sense for your project.

kcq avatar Jun 28 '18 03:06 kcq

in the exceptions to the norm of using singular, provided above, wouldn't "string" (as opposed to "strings") conflict with the reserved keyword string? same for errors and bytes. I think that may be the rationale behind the exception to use plural

mihai-chiorean avatar Jul 30 '19 14:07 mihai-chiorean