I have private repositories with struct: gitlab.com/groups/private-repo's
And I had a problem. When I use go mod tidy or go get -u gitlab.com/groups/private-repo I have:
go: finding module for package itlab.com/group/other-private-repo gitlab.com/group/private-repo imports gitlab.com/group/other-private-repo: cannot find module providing package gitlab.com/group/other-private-repo: unrecognized import path "gitlab.com/group/other-private-repo": reading gitlab.com/group/other-private-repo?go-get=1: 403 Forbidden
or ERROR: The project you were looking for could not be found or you don't have permission to view it.
How to fix this issue? go env:
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/username/Library/Caches/go-build"
GOENV="/Users/username/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/username/go/pkg/mod"
GONOPROXY="gitlab.com/group/*"
GONOSUMDB="gitlab.com/group/*,github.com/username/*"
GOOS="darwin"
GOPATH="/Users/username/go"
GOPRIVATE="gitlab.com/group/*,github.com/username/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/username/go/go1.18.4"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/Users/username/go/go1.18.4/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/username/go/src/gitlab.com/group/private-repo/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/53/kdjyc5f174s7n93vdk2d3jnr0000gn/T/go-build3168396272=/tmp/go-build -gno-record-gcc-switches -fno-common"
my .gitconfig:
[user]
name = username
email = my@email.com
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
insteadOf = https://gitlab.com/
[init]
defaultBranch = main
[core]
autocrlf = input
ssh key added in gitlab