How to resolve Go module declares its path as “x” but was required as “y” between 2 versions


This Content is from Stack Overflow. Question asked by kaizenCoder

I recently had to move private repositories from SaaS Gitlab to an on-premise version. Everything was going well where I did:

  1. Update old go module paths in repo a from to
  2. Add a new tag v1.2.3-new to the latest commit
  3. Update repo b to reference latest tag v1.2.3-new from
  4. Run go mod tidy in repo b and verify it works

Now I have a requirement to reference an older version tag of (originally So in repo a, I checked out the older tag, fixed up the module path to from and tagged it as v1.1.1-new.

In repo b then I referenced with v1.1.1-new. However, this results in:

go: parsing go.mod:
    module declares its path as:
            but was required as:

If I check the v1.1.1-new tag in repo a, the module path is set correctly in the go.modfile:


It is unclear to me why it works with the tag v1.2.3-new on the latest commit but fails when I reference an older commit.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?