3

I needed to fork and modify a repository from GitHub for use in my project, and I followed the directions here to replace the original repository with mine in my go.mod. But when I do go tidy I get a bunch of errors like this:

github.com/chrisrollins65/saml: github.com/crewjam/saml@v0.4.8 (replaced by github.com/chrisrollins65/saml@v1.0.0): verifying go.mod: github.com/chrisrollins65/saml@v1.0.0/go.mod: reading https://sum.golang.org/lookup/github.com/chrisrollins65/saml@v1.0.0: 404 Not Found
        server response: not found: github.com/chrisrollins65/saml@v1.0.0: invalid version: unknown revision v1.0.0

The repository I forked: https://github.com/crewjam/saml

My repository: https://github.com/chrisrollins65/saml

I've ensured I have a tag with v1.0.0, so I'm confused as to why it can't be found.

In the go.mod of the project I'm using this in I have:

replace github.com/crewjam/saml => github.com/chrisrollins65/saml v1.0.0

What am I doing wrong?

Update:

Now it looks like it's finding it? Not sure what changed. But now I get this error, which I thought was exactly what the replace directive was meant to avoid:

saml % go mod tidy
go: finding module for package github.com/chrisrollins65/saml/samlsp
go: finding module for package github.com/chrisrollins65/saml
go: found github.com/chrisrollins65/saml in github.com/chrisrollins65/saml v1.0.0
go: found github.com/chrisrollins65/saml/samlsp in github.com/chrisrollins65/saml v1.0.0
go: github.com/teamwork/saml/samlserver imports
        github.com/chrisrollins65/saml: github.com/chrisrollins65/saml@v1.0.0: parsing go.mod:
        module declares its path as: github.com/crewjam/saml
                but was required as: github.com/chrisrollins65/saml

Edit:

This question was closed as a duplicate. I argue that it is not a duplicate, as the other linked posts only mention using replace in go.mod. I have already done that in this question and the problem still persists.

It appears I had to do as @blackgreen said and ensure the original repository was correctly imported in order for my problem to be resolved. I did not see such an answer posted in any of the linked questions.

Hopefully this post will help any one else who has run into the same problem as me.

Chris
  • 4,277
  • 7
  • 40
  • 55
  • 1
    you have to import `github.com/crewjam/saml` in your Go code. The `replace` then will resolve that dependency to `github.com/chrisrollins65/saml`. If your fork is supposed to have client-facing differences from the original, you have to change it's module name and import the fork as if it were a brand new project – blackgreen Sep 30 '22 at 20:16

0 Answers0