How can I set semantic versioning for a Go project and what are commands to set the version?

huangapple go评论68阅读模式
英文:

How can I set semantic versioning for a Go project and what are commands to set the version?

问题

你可以为Go项目设置语义化版本,并使用以下命令设置版本:

  1. 首先,确保你的Go项目已经初始化。在项目根目录下执行以下命令:

    go mod init <module_name>
    
  2. 接下来,使用以下命令设置初始版本:

    go mod edit -module <module_name> -go <go_version>
    

    其中,<module_name> 是你的项目模块名称,<go_version> 是你要使用的Go版本。

  3. 然后,使用以下命令设置语义化版本:

    go mod edit -module <module_name> -version <version_number>
    

    其中,<module_name> 是你的项目模块名称,<version_number> 是你要设置的语义化版本号。

请注意,以上命令中的 <module_name><version_number> 都需要替换为你实际的值。

英文:

How can I set semantic versioning for Go project and what are commands to set the version?

答案1

得分: 2

go.dev 网站上有一些关于这个的信息。

"Module version numbering" 文档页面提供了有关版本号标准的信息,并提到:

如果您正在开发供他人使用的模块,您可以在发布模块时应用版本号,并在其存储库中标记该模块。有关更多信息,请参阅发布模块

"Publishing a module" 文档页面概述了发布模块的步骤,包括在步骤4和5中如何设置版本号:

  1. 使用 git tag 命令为项目打上新的版本号标签。

对于版本号,请使用一个能向用户表示此版本更改性质的数字。有关更多信息,请参阅Module version numbering

git commit -m "mymodule: changes for v0.1.0"
git tag v0.1.0
  1. 将新的标签推送到源存储库。
git push origin v0.1.0
英文:

The go.dev website has some information about this.

The "Module version numbering" doc page has information about the versioning standards, and mentions:
> If you’re developing modules for others to use, you apply a version number when you publish the module, tagging the module in its repository. For more, see Publishing a module.

The "Publishing a module" doc page outlines the steps for publishing your module, including how to set the version number in steps 4 and 5:
> 4. Tag the project with a new version number using the git tag command.
>
> For the version number, use a number that signals to users the nature of changes in this release. For more, see Module version numbering.
>
>
&gt; git commit -m &quot;mymodule: changes for v0.1.0&quot;
&gt; git tag v0.1.0
&gt;

>
> 5. Push the new tag to the origin repository.
>
>
&gt; git push origin v0.1.0
&gt;

huangapple
  • 本文由 发表于 2023年1月13日 16:16:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75106466.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定