News for hackers. Stuff that matters.
Re:What I learned in 2017 writing Go by lclarkmichalek on Wednesday January 03, 2018 @01:08PM (#16063370)
The `pkg` package is a horrible convention. Having a `cmd` directory makes sense, as each binary needs to be a separate package, but putting all your libraries under a `pkg` directory is unneeded.
Re:What I learned in 2017 writing Go by 013a on Wednesday January 03, 2018 @01:24PM (#16063538)
I hate the pattern primarily because it overloads the name "pkg" which is already used in your go workspace at least one directory up to store compiled library files.

The word "lib" makes more sense. But, also, its unnecessary.

Re:What I learned in 2017 writing Go by jdc0589 on Wednesday January 03, 2018 @05:10PM (#16065754)
I've always used `lib` in every other language. I see no reason to change....
Re:What I learned in 2017 writing Go by lobster_johnson on Wednesday January 03, 2018 @05:38PM (#16066036)
Some projects dump everything in the root of the repo. I find that to be annoyingly messy.

Comingling non-Go dirs with Go code makes it hard to navigate, since some dirs will be Go packages, and some won't. You may want to have documentation (/docs, perhaps), test data (/test?), build output dirs (/build or /dist), Docker/Kubernetes/Helm dirs (/docker, /k8s, etc.), Protobuf files (/proto), and so on, usually all in the root of the project.

Secondly, these directories might conflict with Go package names. We have a project that has a package called "documents", which is about persistent documents, which we'd have preferred to call "docs", but the root already had a /docs folder for actual documentation.

Personally, I prefer "src".

Re:What I learned in 2017 writing Go by frou_dh on Thursday January 04, 2018 @03:15PM (#16073670)
Good points.

More fundamentally, it feels a bit screwy for a multi-faceted 'project' to live wholly inside $GOPATH in the first place. But at the same time, it's natural.

Re:What I learned in 2017 writing Go by wyattjoh on Wednesday January 03, 2018 @01:25PM (#16063547)
Typically, unless I'm writing a shared library, I find myself putting everything under a `internal` folder. It keeps people from importing possibly unstable code until it's exposed.
Re:What I learned in 2017 writing Go by rocmcd on Wednesday January 03, 2018 @03:41PM (#16064880)
I tend to agree, though I also find having everything be in the root of the repository equally rough for larger projects.