internal/cmd/generate-protos: use module= generator option

Now we'll get a generator error if a file is missing a go_package
option.

Change-Id: I89eec716f86956e6c164a61f5531c140b74bc099
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/222378
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
Damien Neil 2020-03-06 14:23:55 -08:00
parent ffbc5fdf5a
commit c92333953e
3 changed files with 13 additions and 3 deletions

View File

@ -5,7 +5,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.proto
package oneoftest
package issue780_oneof_conflict
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@ -90,7 +90,12 @@ var file_cmd_protoc_gen_go_testdata_issue780_oneof_conflict_test_proto_rawDesc =
0x09, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x74, 0x65, 0x73, 0x74, 0x22, 0x27, 0x0a, 0x03, 0x46, 0x6f,
0x6f, 0x12, 0x19, 0x0a, 0x07, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x67, 0x65, 0x74, 0x42, 0x61, 0x72, 0x42, 0x05, 0x0a, 0x03,
0x62, 0x61, 0x72,
0x62, 0x61, 0x72, 0x42, 0x4f, 0x5a, 0x4d, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f,
0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e,
0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x69, 0x73, 0x73,
0x75, 0x65, 0x37, 0x38, 0x30, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
0x6c, 0x69, 0x63, 0x74,
}
var (

View File

@ -6,6 +6,8 @@ syntax = "proto2";
package oneoftest;
option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/issue780_oneof_conflict";
message Foo {
oneof bar { // must be generated as Bar field in Foo struct
string get_bar = 1;

View File

@ -66,6 +66,8 @@ var protoPackages = map[string]string{
"datasets/google_message4/benchmark_message4_1.proto": "google.golang.org/protobuf/internal/testprotos/benchmarks/datasets/google_message4;google_message4",
"datasets/google_message4/benchmark_message4_2.proto": "google.golang.org/protobuf/internal/testprotos/benchmarks/datasets/google_message4;google_message4",
"datasets/google_message4/benchmark_message4_3.proto": "google.golang.org/protobuf/internal/testprotos/benchmarks/datasets/google_message4;google_message4",
"cmd/protoc-gen-go/testdata/nopackage/nopackage.proto": "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/nopackage",
}
func init() {
@ -172,7 +174,8 @@ func generateLocalProtos() {
return nil
}
opts := "paths=source_relative," + protoMapOpt()
opts := "module=" + modulePath
opts += "," + protoMapOpt()
// Emit a .meta file for certain files.
if d.annotateFor[filepath.ToSlash(relPath)] {