Cannot find package problem with Go modules and Golang 1.13.4

340 views
Skip to first unread message

sandy.k...@lawo.com

unread,
Nov 6, 2019, 8:38:15 AM11/6/19
to golang-nuts

I am migrating to using Go modules with Go v1.13.4, and have hit a weird problem with importing packages from a local private repository.

The project structure consists of two library modules, each of which has its own Git repository in our company Gitea server.

mycompany.com
├── libraryA
├── ├── go.mod
├── ├── various .go files
├── libraryB
├── ├── go.mod
├── ├── various .go files
├── ├── test
├── ├── ├── main.go
├── applicationC
├── ├── go.mod
├── ├── various .go files

Library B makes use of features in library A, and so imports library A. 

Application C makes use of both library A and library B

I have set GOPRIVATE=mycompany.com, and enabled an authentication helper, so that the Go tools can correctly extract packages from the private Gitea server, while still pulling public packages from GitHub and so on.

The symptoms are as follows:

  1. Typing "go build ." and "go test ." in root of library A both work fine.
  2. Typing "go test ." in root of library B works fine
  3. Typing "go build ." in test sub-folder of library B works fine
  4. Typing "go build ." in root of application C works fine
  5. Typing "go build ." in root library B FAILS with an error message , saying "cannot find package" at every point where library B Go files attempt to import library A via


What's weird is that identical import statements in Go files that are part of the test package (ie with a _test suffix), or in application C work fine.

I have also tried "go mod verify" and that reports "all modules verified".

Any suggestions as to what is going on, and how to resolve it?

Thanks
Sandy

Reply all
Reply to author
Forward
0 new messages