Go module found but does not contain package error for private repo

Hi, I am trying to import a private repo hosted in gitlab. I have a ~/.git-credentials file setup and a git clone via HTTPS works (it does not expose SSH access). I also go via a proxy and the OS proxy environment variables have been set. No issues downloading public packages.

I have tried the following:

Get package

$ go version
go version go1.13.4 darwin/amd64

$ $ GOPRIVATE="gitlab.example.com" go get -v -u gitlab.example.com/myapp/shared-lib

get "gitlab.example.com/myapp/shared-lib": found meta tag get.metaImport{Prefix:"gitlab.example.com/myapp/shared-lib", VCS:"git", RepoRoot:"https://gitlab.example.com/myapp/shared-lib.git"} at //gitlab.example.com/myapp/shared-lib?go-get=1
go: finding gitlab.example.com/myapp/shared-lib latest

// making sure it didn't silently fail
$ echo $?

However when I run the go vet command I get the following error:

$ go vet
go: finding gitlab.example.com/myapp/shared-lib latest
build gitlab.example.com/myapp/ssp-atlassian-crowd-adaptor: cannot load gitlab.example.com/myapp/shared-lib: module gitlab.example.com/myapp/shared-lib@latest found (v0.0.0-20200223205832-a873abe3e57b), but does not contain package gitlab.example.com/myapp/shared-lib

I can see that the package has been downloaded to $GOPATH/pkg/mod/gitlab.example.com/myapp/shared-lib:

ls -la $GOPATH/pkg/mod/gitlab.example.com/myapp/shared-lib
shared-lib.git@v0.0.0-20200223205832-a873abe3e57b/  shared-lib@v0.0.0-20200223205832-a873abe3e57b/

Within ssp-golib@v0.0.0-20200223205832-a873abe3e57b/ (as per the error above) .go files exist within the pkg dir:

$ ls -la $GOPATH/pkg/mod/gitlab.service.proteuscdnetwork.com/wolfpack/ssp-golib@v0.0.0-20200223205832-a873abe3e57b/
total 32
dr-x------  6 x  staff   204  5 Mar 13:28 .
drwxr-xr-x  4 x  staff   136  8 Mar 19:40 ..
-r--r--r--  1 x  staff    13  5 Mar 13:28 README.md
-r--r--r--  1 x  staff   246  5 Mar 13:28 go.mod
-r--r--r--  1 x  staff  6520  5 Mar 13:28 go.sum
dr-xr-xr-x  4 x  staff   136  5 Mar 13:28 pkg

Can I get some pointers on why this might be failing or instructions on the correct way to do this?

Turns out this was an issue with how I was importing the module in my code.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.