The current usage of GOPATH is no compatible with Go Modules (at least the variant where you do not want to use a GOPATH). Is there already a concept how to support that?
Repos that build with Go 1.11+ and use Go modules don't actually need to use gcr.io/cloud-builders/go -- the main benefit of that builder is that it will arrange your repo into a location in GOPATH for you.
Instead, you can just use the official golang image from dockerhub. For example, the gcs-fetcher directory in this repo uses Go modules and it's build config uses this image.
We should document this better, and eventually deprecate our Go builder once Go module usage is more of a default.
@ImJasonH I think this should be documented in https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/go/README.md for right direction for future users
even I was stuck for while with go modules with this image
Most helpful comment
Repos that build with Go 1.11+ and use Go modules don't actually need to use
gcr.io/cloud-builders/go-- the main benefit of that builder is that it will arrange your repo into a location inGOPATHfor you.Instead, you can just use the official
golangimage from dockerhub. For example, thegcs-fetcherdirectory in this repo uses Go modules and it's build config uses this image.We should document this better, and eventually deprecate our Go builder once Go module usage is more of a default.