Home > Software design >  Unable to access remote repository for go module import
Unable to access remote repository for go module import

Time:08-19

I need to be able to import go modules from my company's private gitlab repository, but there's something I'm very obviously not getting about how it works.

The module in question looks something like this at the top of my go.mod file:

module gitlab.domain.company.com/path/to/repository

Here's my go env:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\E049839\AppData\Local\go-build
set GOENV=C:\Users\E049839\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\E049839\go\pkg\mod
set GONOPROXY=*.company.com
set GONOSUMDB=*.company.com
set GOOS=windows
set GOPATH=C:\Users\E049839\go
set GOPRIVATE=*.company.com
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g  
set CGO_ENABLED=1
set GOMOD=C:\N\the_program\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\E049839\AppData\Local\Temp\go-build416370598=/tmp/go-build -gno-record-gcc-switches

I use ssh exclusively to push and pull from the company's gitlab, so I don't know why that would be my issue, but here's my git.config anyway:

[url "ssh:/[email protected]/"]
    insteadOf = https://gitlab.domain.company.com/
[url "ssh:/[email protected]/"]
    insteadOf = https://gitlab.company.com/

Any time I try to go build or go get for this project, I'm given this error:

go: gitlab.domain.company.com/path/to/lib: unrecognized import path "gitlab.domain.company.com/path/to/lib": https fetch: Get "https://gitlab.domain.company.com/path/to/lib?go-get=1": dial tcp xx.xx.xxx.xxx:xxx: connectex: No connection could be made because the target machine actively refused it.

Some info redacted obviously.

My version of go is 1.19 running on Windows. I'm kind of at my wit's end trying to fool with this module, to the extent that I'm considering rewriting the entire application in a language with sensible version control.

CodePudding user response:

Your ssh url looks a little funky. My github one used to look like ssh://. That error means it is not using ssh, so it is not reading the config correctly.

CodePudding user response:

There are known issues[1] [2] with retrieving go modules from gitlab projects, particularly those that reside within subgroups.

There's a few workarounds described in that issue (one of which you are using) but this does not work in all circumstances like subgroups nested beyond top-level-group/project.

For self-hosted instances you can enable the go proxy which also eliminates the problem. Or if you have your project directly under a top-level group, this will also avoid the problem.

In your case, however, this seems to be [additionally] a misconfiguration because the error is a networking issue (despite you being able to access these services normally):

No connection could be made because the target machine actively refused it

This is a networking error not necessarily related to gitlab or go get...

  • Related