Description
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 as gen/<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 from gitlab.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 with protoc-gen-go
, but some are playing with code generated by protoc-gen-gofast
.
Our decision was to have two URL serving goproxies: https://goproxy.example.com/go
and https://goproxy.example.com/gofast
where the first one requests for 3rd party goproxies and returns code generated with protoc-gen-go
and the other one works exactly the same except it would return code generated with protoc-gen-gofast
. We thought we would simply use different GOPROXY
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
or GOMODCACHE
or whatever to control modules cache. This would ease the development if editor/IDE supports project profiles.