3

I added the dependency to go.mod:

require (
    github.com/labstack/echo/v4 v4.3.1
)

replace (
    github.com/labstack/echo/v4 => example.com/echo/v4.git v4.3.1
)

And getting error like replace example.com/echo.git: version "v4.3.1" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4. Tag with the required version exists in the repo.

While I'm tried to play with the version I got something like v1.2.1-0.20210520145606-2defe74d39f0, but when I set my replace section like:

replace (
    github.com/labstack/echo/v4 => example.com/echo/v4.git v1.2.1-0.20210520145606-2defe74d39f0
)

I'm getting the error errno=Connection refused related to the private git server.

Could you please advise what I'm doing wrong and how I can replace dependency with my private fork?

5
  • I think you don't need to specify the .git Commented May 24, 2021 at 14:59
  • @Matteo without .git I also get an error: version "v4.3.1" invalid: unknown revision echo/v4.3.1 Commented May 24, 2021 at 15:01
  • 4
    Is the name of your repo actually v4.git? The v4 part of the import path is only a tag in the original repo, it does not correspond to an actual path or repo name. Commented May 24, 2021 at 15:06
  • @JimB This is what me confusing also. If I change replace section to this github.com/labstack/echo => bucket.digitalarsenal.net/elpaso/backend/libs/echo v4.3.1 it doesn't help also. replace example.com/echo: version "v4.3.1" invalid: unknown revision libs/echo/v4.3.1. But tag with this version exists. Commented May 24, 2021 at 15:11
  • 1
    @Ole I guess that error is actually from sum.golang.org. I’ve left an answer to that effect but if not please edit with the full output from running go get. Commented May 24, 2021 at 22:20

2 Answers 2

2
  • Make sure your repo path is accurate. v4.git means the repo is called v4; if that’s true that’s ok, but if not replace it with the correct name of the repo and keep the v4.x.x tag after it.

  • If the fork is private it’s probably not accessible by sum.golang.org. Make sure GOPRIVATE is set to your private fork so Go does not try to get the checksum.

    go env -w GOPRIVATE=example.com
    
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the suggestion! When I specified the correct path to the repo without any wired suffices in replace section github.com/labstack/echo/v4 => example.com/echo.git v4.3.1 I got an error: replace example.com/echo.git: version "v4.3.1" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v4. Tag 4.3.1 exists in the repo, I doublecheck this.
In my forks go.mod file I have module github.com/labstack/echo/v4
2

If the replacement repo is hosted in a Git repository at example.com/echo, then the path to the replacement should probably be example.com/echo.git/v4:

replace (
    github.com/labstack/echo/v4 v4.3.1 => example.com/echo.git/v4 v4.3.1
)

If the example.com server serves go-import metadata, then you may be able to omit the .git suffix entirely:

replace (
    github.com/labstack/echo/v4 v4.3.1 => example.com/echo/v4 v4.3.1
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.