TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Go modules and semantic import versioning

2 点作者 TXV超过 5 年前
With the release of Go 1.13, I&#x27;ve recently started digging into Go modules in order to upgrade my code base.<p>After a whole day of reading and researching, I&#x27;m still baffled by some of the features. In particular, I find problematic the combination of these two pieces of docs:<p>1 About semantic import versioning: https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;wiki&#x2F;Modules#semantic-import-versioning<p>2 Releasing a v2+ module: https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;wiki&#x2F;Modules#releasing-modules-v2-or-higher<p>Basically they turned a piece of advice into a requirement. I&#x27;m talking about the import compatibility rule, summarized by this statement: &quot;If an old package and a new package have the same import path, the new package must be backwards compatible with the old package.&quot;<p>This mostly results in having to maintain either separate branches, or even same-branch separate sub-directories containing the major version code. Example: https:&#x2F;&#x2F;github.com&#x2F;nicksnyder&#x2F;go-i18n<p>The main issue I have with this advice becoming a requirement is that VCS&#x27;s (VERSION control systems) <i>inherently</i> manage versions. I can prevent you from downloading a backwards-incompatible version of my code just with tags and semver.<p>I understand that import versioning might help solve the problem of diamond imports, but I don&#x27;t see why the solution must be a toolchain-level VCS that overlaps with my repository VCS.<p>I must be missing some major point here. I would love to hear HN&#x27;s opinion on this.

1 comment

sethammons超过 5 年前
For a targeted question like this, I&#x27;d consider posting to <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;golang&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;golang&#x2F;</a> or <a href="https:&#x2F;&#x2F;groups.google.com&#x2F;forum&#x2F;#!forum&#x2F;golang-nuts" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;forum&#x2F;#!forum&#x2F;golang-nuts</a>.<p>Go packages have tried to be backwards compatible in general since the beginning; it is part of the culture following the Go compatibility promise. Developers have been free to ignore this.<p>The idea is fairly straight forward: as you update your packages, they should be backwards compatible. If it is not, you should make a new major version, and this is typically done with a new subdirectory&#x2F;package (like a &#x2F;v2). Nothing more to it than that.