Module found, but does not contain package

I cannot successfully get submodules at a certain version. I created a test repo at GitHub in order to make the issue reproducible.

How to repdouce:

Create skeleton hugo site and enter it:

hugo new site my-new-site
cd my-new-site

Initialize site as module:

hugo mod init

Now import root module from test repo, this works fine:

hugo mod get
go: downloading v0.1.0

Now, when I try to import submodule from test repo at version v0.1.0, I’m confronted with an error:

hugo mod get
go get: module found, but does not contain package

As a workaround, I specified the commit ID, this works:

$ hugo mod get
go: downloading v0.0.0-20220130204615-f66df2c9dc42

I want to use the tag v0.1.0 if possible. Is there any way to achieve that? Am I doing anything wrong here? I added an empty go file with a package declaration in directory package, but that didn’t cure the problem.

This might be helpful:

We version the submodules independently by applying separate git tags

What this error says is that tag v0.1.0 exists, but in your go.mod in that tag the name of the module is not When you tagged your module had errors. If you NEED to have v0.1.0 then delete the tag both local and remote fix the module so that it installs without warnings and errors and re-tag. If the tag is arbitrary and you just want the latest tag, then make a new tag that is higher than the one before (v0.1.1 or v0.2.0) and it will install. That specific tag 0.1.0 will NEVER work which is not a fault of Hugo or Go, it’s a wrong configuration in the tag.

In my own projects I increase the tag number and just run the install or update command without tag-number and it will load the latest tag. Keep an eye on the name, if you use v at the start, then always use v at the start or Github might return weird results of what it thinks the “latest” tag is (in my experience, maybe it’s fixed or was never an issue).

That was really helpful, thanks a lot!

I had to add a second tag package/v0.1.0. Afterwards, I could successfully import the submodule via

hugo mod get

That solved my problem, again thanks for guiding me on the right track!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.