0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I'll update my question. I actually want to publish one on github, so in another go.mod file I can import my first package using a controlled version.
I tried git tag v1.1.0 on the first package, but when I tried to import it in another go.mod file I got an error unknown revision v1.1.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.