Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goodbye pkg directory #57

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Goodbye pkg directory #57

wants to merge 1 commit into from

Conversation

kfcampbell
Copy link
Member

I've been thinking about this a lot. There's no question I've been one of the more staunch defenders of the pkg directory; I like the cleanliness of a root directory with the source code tucked into a neatly identifiable folder.

However, there's also no question I've been outvoted on this front, and as I work through what nice client abstractions might look like in octokit/go-sdk#52, I'm debating going the other way. First, there's the repetition in any top-level Go file: package pkg, which is ugly (though it could be remedied by switching to src or something similar). Second, I was clinging to something that isn't that big of a deal: inside the pkg directory of go-sdk on the rate-limiting branch, there's only four other directories, which even if expanded wouldn't be the end of the world.

Also, I've read our esteemed GitHub colleague Dave Cheney's post here, which mentions:

Possibly because of the early use of a pkg/ directory to hold package—​and the corresponding cmd/ directory to hold commands (package main) this practice of putting your packages in an empty pkg/ directory has spread to other Go projects. This practice was never a recommendation, just a result of the original Makefile based build system.

In September 2014, the stdlib moved away from storing package code in an otherwise empty pkg/ directory, and you should follow their lead. Other than a superficial symetary [sic] with cmd/ putting packages in a pkg/ directory is needless boilerplate and distracts from the potentially more useful internal/ directory.

One thing that does concern me a bit is that removing the pkg directory would mean any code currently in Go files immediately belonging to that folder would have to find a different directory in order to continue to be exported. This could lead to repetition or potentially poor naming elsewhere as package names are forced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant