cmd/go: cannot vendor protoc-gen-go if not imported in module code import #31239
Labels
FrozenDueToAge
modules
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of protobuf and what language are you using?
Version: v1.3.1
What did you do?
go build -mod=vendor sourcefile.go
What did you expect to see?
I expected my go.mod dependency of github.com/golang/protobuf to be included in the vendor folder, even though it doesnt exist as an import in any of my go files because i need the packages proto and protoc-gen-go for using protoc to generate .proto files.
I should be able to include a vendored dependency thats not imported by my go source code files to allow my dockerfile to build vendored .proto files without pregenerating them and commiting them to a repo. The reason for this is to ensure other users of my library do not ignore the .proto file and just use *.pb.go which could possibly be out of sync with its related .proto. If they have to use protoc everytime they pull my .proto file from my package then they are guarunteed to be in sync.
What did you see instead?
/home/$USER/dev/go/src/github.com/username/modulename/vendor/github.com/golang/protobuf/proto no such file or directory
go.mod
Extra information:
Including this import
github.com/golang/protobuf/protoc-gen-go
in a empty go file calledtools.go
throws a go error saying that protoc-gen-go has a main method so its a compiled tool and not a shared library.This prevents any type of import being allowed when trynig to vendor protoc code.
When using
-mod=vendor
themod.go
file is completely ignored so there is not even a way to put an indirect dependency in there.The only option is to not use vendoring, and that requires me to put my gitlab https auth credentials directly in the docker file or environment variable so i can download gitlab dependencies which is not ideal.
The text was updated successfully, but these errors were encountered: