Go 1.14.3
I have a coverage file that looks like this (trimmed for brevity):
mode: atomic
fooco/barproj/api/dao/dataSharingService/api.go:23.128,25.2 1 7
fooco/barproj/api/dao/highlights/highlights_dao.go:20.13,22.2 1 1
fooco/barproj/api/dao/testresult/testresult_dao.go:149.11,152.51 3 2
fooco/barproj/api/middleware/logging.go:19.44,20.72 1 4
The code is in a monorepo at /Users/jcollum/work/barproj. So dataSharingService/api.go is at: src/api/dao/dataSharingService/api.go and highlights_dao.go is at src/api/dao/highlights/highlights_dao.go.
Imports are like "fooco/barproj/pkg/types".
My best attempt here was to add entries to GOPATH:
GOPATH="/Users/jcollum/.go:/Users/jcollum/work/barproj/src/pkg/types:/Users/jcollum/work/barproj/src/pkg/dao" go tool cover -html="tests/coverage/api-coverage.out"
But that failed:
cover: cannot find package "fooco/barproj/api/dao/dataSharingService" in any of:
/usr/local/Cellar/go/1.14.3/libexec/src/fooco/barproj/api/dao/dataSharingService (from $GOROOT)
/Users/justin.collum/.go/src/fooco/barproj/api/dao/dataSharingService (from $GOPATH)
/Users/justin.collum/work/barproj/src/pkg/types/src/fooco/barproj/api/dao/dataSharingService
/Users/justin.collum/work/barproj/src/pkg/dao/src/fooco/barproj/api/dao/dataSharingService
Coworker who is way ahead of me in the Go manual says this won't be possible without moving code around which sounds code smelly as heck.
So is there any way to manipulate the GOPATH before calling cover to get it to see code that is in "non-standard" Go paths? Or is there a better way to solve this than moving files around?
Some caveats:
- the Go docs discourage the use of symlinks for GOPATH but don't give a reason
- this is a team of 5+ people so asking people to move code around is a bit of a big ask
- reorganizing the repo is not an option I can consider
- GVM isn't an option, the team prefers not to use it