IssueRaiser

pkg directory should not be recommended for use

The general consensus of the Go community has been converging on the idea that the `pkg/` directory is a useless abstraction / indirection. Instead, people are encouraged to either put the packages in the top-level of the repository, or to create a repository structure that structures things based on their primary functionality of domain in the business logic. So while in your example you may encourage people to have the following layout: ``` pkg/ server/ handlers/ poller/ config/ manager/ ``` We instead would prefer: ``` server/ handlers/ poller/ config/ manager/ ``` This may seem innocuous, but because this project has asserted itself as some sort of Go standards body what is being recommended here is being taken seriously. In the Slack workspace, where there are over 30k registered users, we quite often need to correct people who are using `pkg/` and have them ignore the recommendations here. Some of the things recommended here are good, and I'd like to be able to use them as a resource. That said, considering the current `pkg/` recommendation we're hard-pressed to use this as a resource because we have to tell people to ignore certain parts.

Posted by theckman on Aug 14, 2018, 3:59 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Sysadmin)

pkg directory should not be recommended for use

theckmanAug 14, 2018, 3:59 PM

The general consensus of the Go community has been converging on the idea that the `pkg/` directory is a useless abstraction / indirection. Instead, people are encouraged to either put the packages in the top-level of the repository, or to create a repository structure that structures things based on their primary functionality of domain in the business logic. So while in your example you may encourage people to have the following layout: ``` pkg/ server/ handlers/ poller/ config/ manager/ ``` We instead would prefer: ``` server/ handlers/ poller/ config/ manager/ ``` This may seem innocuous, but because this project has asserted itself as some sort of Go standards body what is being recommended here is being taken seriously. In the Slack workspace, where there are over 30k registered users, we quite often need to correct people who are using `pkg/` and have them ignore the recommendations here. Some of the things recommended here are good, and I'd like to be able to use them as a resource. That said, considering the current `pkg/` recommendation we're hard-pressed to use this as a resource because we have to tell people to ignore certain parts.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue