Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go mod replace dependency with private fork

Tags:

git

go

go-modules

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?

like image 889
Oleksandr Savchenko Avatar asked Jan 23 '26 20:01

Oleksandr Savchenko


1 Answers

  • 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
    
like image 119
grg Avatar answered Jan 25 '26 09:01

grg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!