0

I've read several articles about this issue. But all of the recommendations are for use in the go.mod file. I have a private repo in azure devops and I am using the command go get to get the repo and install it. I have followed various tutorials about how to get it configured so I can download from my own private azure devops repo and I believe this is all setup correctly. I run the command go get <my/azure/devops/go/repo> And I get the error

go: dev.azure.com/me/az-cloud/_git/go_poc_library.git@v0.0.1: parsing go.mod: module declares its path as: go_poc_library but was required as: dev.azure.com/me/az-cloud/_git/go_poc_library.git

The go.mod file of my service consuming the library is like this:

replace dev.azure.com/me/az-cloud/_git/go_poc_library v0.0.1 => /go_poc_library

How do I solve this issue?

slipperypete
  • 5,358
  • 17
  • 59
  • 99
  • 1
    You can't solve this with the `get` command, the module name does not match its `go.mod` – JimB Jun 28 '23 at 18:23
  • @JimB I am doing the replace thing in the go.mod file. (forgot to mention it). What else can be done? – slipperypete Jun 28 '23 at 18:28
  • Does this answer your question? [What's the proper way to "go get" a private repository?](https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository) – Gavin Jun 28 '23 at 18:30
  • 1
    @slipperypete, If the module is called `dev.azure.com/me/az-cloud/_git/go_poc_library`, then the `go.mod` must use the same name. `replace` let's you locate a different source or version, but it cannot change its name. – JimB Jun 28 '23 at 18:31
  • @JimB I have tried this by naming the module as the exact same as the URL in the command. It still does not work. – slipperypete Jun 28 '23 at 18:35
  • @Gavin that post looks like it is about setting up to be able to use a private repo. I believe I have done that corrrectly and given the error message I think go get is getting into my ADO, it's some configuration with the repo that's the issue. I think. – slipperypete Jun 28 '23 at 18:40
  • @slipperypete If you did that there would be a different error, what was that error? – JimB Jun 28 '23 at 18:40
  • @JimB I changed the module name of the library repo to dev.azure.com/me/az-cloud/_git/go_poc_library but i get this error go: dev.azure.com/me/az-cloud/_git/go_poc_library.git@v0.0.1: parsing go.mod: module declares its path as: go_poc_library but was required as: dev.azure.com/me/az-cloud/_git/go_poc_library.git – slipperypete Jun 28 '23 at 18:54
  • So I get the same error – slipperypete Jun 28 '23 at 18:55
  • The error says `module declares its path as: go_poc_library`, which means that go.mod still shows `go_poc_library` and not the full name. Make sure that `go.mod` matches, and _all imports_ using that module use the same module name; nothing should refer to that module only by `go_poc_library` if you want it to be discoverable from the repository address. – JimB Jun 28 '23 at 19:04
  • @JimB there literally is no reference to only `go_poc_library` in the entire project. Everything is changed to the new name `dev.azure.com/danielptm/daniels-az-cloud/_git/go_poc_library` However the name of the repo itself is `go_poc_library` it would not allow me to change it to the name of the module. Could the problem be an azure caching thing or something? – slipperypete Jun 28 '23 at 19:09
  • You could be fetching the cached proxy response. Did you set `GOPRIVATE` like in the linked answer? – JimB Jun 28 '23 at 19:11
  • @JimB Yes this is set in .zshrc as `export GOPRIVATE=dev.azure.com/me` – slipperypete Jun 28 '23 at 19:15
  • Ok. I got this figured out. There was caching thing going on with azure devops. I had to create a new repo, and push the code, once I did that it worked. I would call this an ADO bug or terrible user experience. – slipperypete Jun 28 '23 at 19:29

0 Answers0