Russ Cox: 这不是 Go 标准的程序结构

看到一个关于 Go 项目结构的讨论,分享给大家。

Go 生态圈有一个知名的项目 github.com/golang-standards/projec... (接近 3w 个 star),有一个 issue github.com/golang-standards/projec...

The README makes clear that this is not official, but even the claim “it is a set of common historical and emerging project layout patterns in the Go ecosystem” is not accurate.
For example, the vast majority of packages in the Go ecosystem do not put the importable packages in a pkg subdirectory. More generally what is described here is just very complex, and Go repos tend to be much simpler.
It is unfortunate that this is being put forth as “golang-standards” when it really is not. I’m commenting here because I am starting to see people say things like “you are not using the standard Go project layout” and linking to this repo.
by Russ Cox

Google 翻译:

README 明确表示这不是官方的,但即使是“它是 Go 生态系统中一组常见的历史和新兴项目布局模式”的说法也不准确。
例如,Go 生态系统中的绝大多数包都不会将可导入的包放在 pkg 子目录中。这里描述的目录结构非常复杂,而 Go 存储库往往要简单得多。
不幸的是,这实际上不是“golang-standards”。我在这里发表评论是因为我开始看到人们说“你没有使用标准的 Go 项目布局”并链接到这个 repo。

Russ Cox 是谁?

Russ Cox 在多年以前就是 Go Team 的技术负责人(Leader),也是 Go 源码的最多贡献者:

Russ Cox: 这不是 Go 标准的程序结构

所以基本上算是 Go 官方的发言了。

事件的起因是因为这个 Issue —— github.com/adonovan/spaghetti/pull... 。某个开源活跃者看不惯某个项目的目录结构,故提交了一个 PR ,意将整个项目重构符合 golang-standards/project-layout 的标准。

分享给大家,在做项目结构规划时,心里也有个底。

摈弃世俗浮躁,追求技术精湛
Summer
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!