Publish a GO package to github

I have this package that I wrote, let’s call it mypkg. It is available on

Once the package was completed, I did this:

  • git tag -a ‘1.00.00’ -m ‘version 1.00.00’
  • go mod init
  • git add . && git commit -m ‘my commit message’
  • git push --follow-tags origin ← push the tag to the repo

And I’m done, package-wise (… I think ?)

Now on the software that might wish to use mypkg, I do this, in the tool’s rootdir (where its go.mod file resides):

  • go get
  • Then, in every source file that needs the package I add this in the import statement:

The problem is with go get : it seems to download a version v0.00.00-with_some_hash, instead of __1.00.00

Why ?

Hello there, did you update your go.mod file? You also need to check what version is marked as release on GitHub.

go mod init && go mod tidy.

On github’s side, I only tagged the code, did not release it. I thought that tagging was sufficient ? This must be my issue, then

What version of the package appears in your “go.mod” file?

it does not show :-/

The package to be published is tagged this way: git tag -a '1.0.0' -m 'First version' and git push --follow-tags origin … On github, I’ve published a release from that 1.0.0 tag.

Now, in the tool that should use the tool, I do: go get

The output shows this:
go: added v0.0.0-20240401010128-eac52ef19ef8

The require section of go.mod shows the same

It’s as if GO ignores the actual tag/release. If I check in my GOROOT ($HOME/go/pkg/mod/, MYPKG is obviously downloaded there, with the same bogus version number

it could be because tag should be v*.*.*, try to change your tag and change version in mod file explicitly.

tags have to be prepended with v ? ho, I missed that one.

I am using Jetbrains’ GoLand, I thought the IDE might have been messing things up.

Will try later today and will let you know.

Ok, I tested, and it works fine, I’ve managed to import my package and use it in some other tool.

It was just a matter of tagging my package with a v prefix: v1.0.0 …

Thanks, @lemarkar !

1 Like

Same problem, different package I’m trying to publish:

You see, the release IS THERE.

I add the following line to go.mod: v1.0.0

Then run go mod tidy, and it then complains this way: verifying go.mod: reading!functions@v1.0.0: 404 Not Found
        server response: not found: invalid version: unknown revision v1.0.0

What gives ?

OK… So I’ve pushed multiple updates to the code (documentation, some extra functions, etc).

  • git add .
  • git commit -m ‘Extra functions, bla bla bla’
  • git tag -a ‘v1.1.0’, -m ‘my message’
  • git push --follow-tags origin

And then, go mod tidy, edited go.mod with a new version, go mod tidy again (yeah I know redundant steps here), and… MAGIC, it worked.

Something tells me me that the whole link between, GOLANG, and most likely, Jetbrains’ GOLAND is fragile.

I mean… I’m a seasoned DevOps guy, maybe not-so in GO, but still… scratching my head until you can see the scratch marks is not an usual way for me.