cmd/go: issues with shared $GOPATH/pkg/mod cache and autogenerated modules #32235
Labels
FrozenDueToAge
modules
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Hi!
At my job we have a single repository with proto-files grouped by directories. Something like
gitlab.example.com/common/schema/<service path>/<file.proto>
We were generating this into
$GOPATH/src/gen/<service path>/<file.go>
and import this asgen/<service path>
Now we did a server which acts like a good go modules proxy except the case when it is requested for
gitlab.example.com/common/schema/<service path>/v34
. It generates go code fromgitlab.example.com/common/schema/<service path>/*.proto
files and return them as regular go module. Sounds nice and it works great in most cases except one thing: most our projects use code generated withprotoc-gen-go
, but some are playing with code generated byprotoc-gen-gofast
.Our decision was to have two URL serving goproxies:
https://goproxy.example.com/go
andhttps://goproxy.example.com/gofast
where the first one requests for 3rd party goproxies and returns code generated withprotoc-gen-go
and the other one works exactly the same except it would return code generated withprotoc-gen-gofast
. We thought we would simply use differentGOPROXY
for different projects and everything will be great.And this doesn't work that easy unfortunately: we have shared
$GOPATH/pkg/mod
– cache directory for downloaded modules. And we will have exactly the same autogenerated module of certain version for project A if we have already requested this version of the module for project B despite having different sources.Sure, we can manually clean cache dir but this is … ugly. We would probably have different cache directories with different
GOPATH
, but we would prefer to keep it the same.So I have a proposal: a new environment variable called
GOCACHE
orGOMODCACHE
or whatever to control modules cache. This would ease the development if editor/IDE supports project profiles.The text was updated successfully, but these errors were encountered: