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>
diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
index 65bf3b5..e4164c5 100644
--- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
+++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
@@ -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 @@
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 (
diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.proto b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.proto
index e96d472..d6d269d 100644
--- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.proto
+++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.proto
@@ -6,6 +6,8 @@
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;
diff --git a/internal/cmd/generate-protos/main.go b/internal/cmd/generate-protos/main.go
index 2008c61..84b8bfe 100644
--- a/internal/cmd/generate-protos/main.go
+++ b/internal/cmd/generate-protos/main.go
@@ -66,6 +66,8 @@
"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 @@
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)] {