I am creating 3 separate go projects: ace
, aces-client
and a library shared by both projects aceslib
. I am having trouble including the shared library according to the go-documentation (https://golang.org/doc/code.html#Library)
all go files in aceslib share the package-name aceslib
. I am including the library in ace and aces-client with import lib "aceslib"
. I can build the library with go build
and it gets installed with go install
, in the directory listing one can see that the file go/pkg/windows_amd64/aceslib.a
gets created.
But when I try to build ace
or ace-client
go complains:
$ go build
build ace: cannot load aceslib: cannot find module providing package aceslib
My go setup:
$ go version
go version go1.12.9 windows/amd64
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Yulivee\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Yulivee\go
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Yulivee\go\src\ace\go.mod
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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\Yulivee\AppData\Local\Temp\go-build024649150=/tmp/go-build -gno-record-gcc-switches
Directory Structure:
.
├── bin
│ ├── ace-client.exe
│ └── ace.exe
├── pkg
│ ├── mod
│ │ ├── cache
│ │ └── golang.org
│ └── windows_amd64
│ ├── ace
│ ├── aceslib.a
│ └── golang.org
└── src
├── ace
│ ├── README.md
│ ├── go.mod
│ ├── go.sum
│ └── main.go
├── ace-client
│ └── main.go
├── aceslib
│ ├── README.md
│ ├── crypto.go
│ ├── go.mod
│ └── utils.go
What am I missing?
Things I have tried, that did not help and lead to the same error:
$ go clean -i -x -cache -modcache
$ chmod 755 go/pkg/windows_amd64/aceslib.a
$ go get
build ace: cannot load aceslib: cannot find module providing package aceslib
$ rm -rf go/pkg/*