TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

I'll Take Pkg over Internal

41 pointsby pythonistover 5 years ago

7 comments

0xFACEFEEDover 5 years ago
Love Go. But this is yet another case where language creators opted out of standardizing something they should have. The community is left to fend for themselves and squabble over naming conventions and boilerplate.<p>The golang-standards&#x2F;project-layout repo is the inevitable outcome. An over-engineered land grab (let&#x27;s call it what it is). But 11k stars is a decent indicator of Go programmers wanting some kind of authoritative standard so they don&#x27;t need to re-organize their now-small but tomorrow-large projects over and over.<p>A recent issue that parallels this one is package management. So many monstrosities came out of that until go modules was formalized :P
enneffover 5 years ago
My advice is to not overthink it and do what works for you.<p>IMO,<p>don’t use a pkg directory. It only makes your import paths more unwieldy.<p>Don’t use internal unless you have a package that is an awkward implementation detail that must be shared between packages for expedience. Usually this can be factored away with some effort but sometimes it’s not worth it.<p>Do use cmd directories. They make it clear what “go install” will do.<p>But otherwise really just pick any approach and move on with your life.
评论 #21436480 未加载
dmlittleover 5 years ago
I like the use of pkg&#x2F; as it allows you to separate your source code from other things that might be in the repository such as a README, LICENSE, Dockerfile, Makefile, linter configurations, go version configuration, etc. These things usually live in the root of the repository so you know to look for them there but if you also have your source code there it makes things harder to find.<p>This is also one of the reasons why some other programming languages might have adopted the standard of src&#x2F; or lib&#x2F;.
blaisioover 5 years ago
&gt; Most people who would bother with the matter at all would admit that the layout of Go projects is in a bad way.<p>... How? They just don&#x27;t tell you that files have to be under a certain directory. It&#x27;s beyond me how that upsets people.<p>I think this is just people looking for something to argue about. The go team can&#x27;t standardize <i>everything</i>.
评论 #21438280 未加载
Insanityover 5 years ago
Somehow the text was hard to read &#x2F; follow for me. Might be because I&#x27;m a bit tired though.<p>Anyway, OT: Even though there might not be an &quot;official&quot; standard, there is indeed a community standard.<p>If I explore other projects I hope to see some common structures reflected there, which makes it easier to browse the code.
meddlepalover 5 years ago
I personally use a pkg directory because I like an uncluttered root and don&#x27;t want to end up at some point having a namespace collision with something that would be better placed in the root directory.
awinter-pyover 5 years ago
go modules have too many weird rules<p>just import file paths like everyone else -- it&#x27;s simpler and not obviously worse