简体   繁体   中英

Control Go package version

I am looking for a way to control a go package version on github, something similar to the "version" key in a package.json file (for nodejs packages).

In a package.json

{
  "version": "1.0.1"
}

I want to import my package in another one, both use go modules. In my second package, my go.mod file looks like this:

module myPackage

go 1.14

require(
  github.com/myAwesomePackage v0.0.0-20200531102207-93175fe4ed5f
)

Now I'd like to make changes to myAwesomePackage, so I can rewrite myPackage mod file like this:

module myPackage

go 1.14

require(
  github.com/myAwesomePackage v1.1.0
)

I tried git tag 1.1.0 and git tag v1.1.0 in myAwesomePackage, but myPackage gives the following error when trying to update:

invalid version: unknown revision v1.1.0

UPDATE

git tag actually worked, the issue seemed to come from my Ide (GoLand). Just rewriting version in go.mod file didn't worked, I had to remove the entire line in require statement, then let IntelliJ sync again the dependencies. Now myAwesomePackage is imported with the correct version.

It's unclear whether you're publishing a Go module, or whether you're depending on one. Either way, it's simple enough; if you're publishing one, you can just tag a version using git tag . If you're depending on one and would like to lock to a specific version, you can simply modify your project's go.mod file and choose a version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM