Przeglądaj źródła

internal/cmd/generate-protos: generate test for testdata

Running "go build ./..." does not descend into testdata directories.
However, the testdata in this repository is source code that is
intended to build properly. We could rename the directory, but that does
not test whether the generated packages can initialize properly.

Thus, we generate a trivial test that simply blank imports all packages.

Doing this reveals that some of the generated files have incorrect imports,
leading to registration conflicts.

To avoid introducing a dependency on gRPC from our go.mod file, we put
the testdata directories in their own module. Also, we avoid running
internal/testprotos through the grpc plugin because the servie and method
definitions in that directory are more for testing proto file initialization
rather than testing grpc generation.

Change-Id: Iaa6a06449787a085200e31bc7606e3ac904d3180
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/164917
Reviewed-by: Damien Neil <dneil@google.com>
Joe Tsai 7 lat temu
rodzic
commit
d56458e71b
33 zmienionych plików z 262 dodań i 352 usunięć
  1. 11 0
      cmd/protoc-gen-go-grpc/testdata/gen_test.go
  2. 9 0
      cmd/protoc-gen-go-grpc/testdata/go.mod
  3. 28 0
      cmd/protoc-gen-go-grpc/testdata/go.sum
  4. 29 0
      cmd/protoc-gen-go/testdata/gen_test.go
  5. 8 0
      cmd/protoc-gen-go/testdata/go.mod
  6. 23 0
      cmd/protoc-gen-go/testdata/go.sum
  7. 6 6
      cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
  8. 1 1
      cmd/protoc-gen-go/testdata/imports/fmt/m.proto
  9. 7 6
      cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
  10. 1 1
      cmd/protoc-gen-go/testdata/imports/test_a_1/m1.proto
  11. 6 6
      cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
  12. 1 1
      cmd/protoc-gen-go/testdata/imports/test_a_1/m2.proto
  13. 6 6
      cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
  14. 1 1
      cmd/protoc-gen-go/testdata/imports/test_a_2/m3.proto
  15. 6 6
      cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
  16. 1 1
      cmd/protoc-gen-go/testdata/imports/test_a_2/m4.proto
  17. 7 7
      cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
  18. 1 1
      cmd/protoc-gen-go/testdata/imports/test_b_1/m1.proto
  19. 7 7
      cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
  20. 1 1
      cmd/protoc-gen-go/testdata/imports/test_b_1/m2.proto
  21. 6 6
      cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
  22. 1 1
      cmd/protoc-gen-go/testdata/imports/test_import_a1m1.proto
  23. 6 6
      cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
  24. 1 1
      cmd/protoc-gen-go/testdata/imports/test_import_a1m2.proto
  25. 9 9
      cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
  26. 1 1
      cmd/protoc-gen-go/testdata/imports/test_import_all.proto
  27. 0 2
      go.mod
  28. 0 21
      go.sum
  29. 9 8
      integration_test.go
  30. 67 27
      internal/cmd/generate-protos/main.go
  31. 0 217
      internal/testprotos/test/test_grpc.pb.go
  32. 1 1
      regenerate.bash
  33. 1 1
      test.bash

+ 11 - 0
cmd/protoc-gen-go-grpc/testdata/gen_test.go

@@ -0,0 +1,11 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style.
+// license that can be found in the LICENSE file.
+
+// Code generated by generate-protos. DO NOT EDIT.
+
+package main
+
+import (
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go-grpc/testdata/grpc"
+)

+ 9 - 0
cmd/protoc-gen-go-grpc/testdata/go.mod

@@ -0,0 +1,9 @@
+module github.com/golang/protobuf/v2/cmd/protoc-gen-go-grpc/testdata
+
+require (
+	github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480
+	github.com/golang/protobuf/v2 v2.0.0
+	google.golang.org/grpc v1.19.0
+)
+
+replace github.com/golang/protobuf/v2 => ../../..

+ 28 - 0
cmd/protoc-gen-go-grpc/testdata/go.sum

@@ -0,0 +1,28 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480 h1:K3kcmzT/cPx8K4eprFqWF4cLZIxiOLNm+vKmNqQFCBw=
+github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480/go.mod h1:asK8yRb/+zxJTE0SbTESCku/4OjiDfbPwk4rEyIatUA=
+github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 h1:dgd4x4kJt7G4k4m93AYLzM8Ni6h2qLTfh9n9vXJT3/0=
+golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20180928181343-b3c0be4c978b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20180831171423-11092d34479b h1:lohp5blsw53GBXtLyLNaTXPXS9pJ1tiTw61ZHUoE9Qw=
+google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

+ 29 - 0
cmd/protoc-gen-go/testdata/gen_test.go

@@ -0,0 +1,29 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style.
+// license that can be found in the LICENSE file.
+
+// Code generated by generate-protos. DO NOT EDIT.
+
+package main
+
+import (
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/annotations"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/comments"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/base"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/ext"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/extra"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/proto3"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/fieldnames"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub2"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/fmt"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_2"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_b_1"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/issue780_oneof_conflict"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/nopackage"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/proto2"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/proto3"
+)

+ 8 - 0
cmd/protoc-gen-go/testdata/go.mod

@@ -0,0 +1,8 @@
+module github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata
+
+require (
+	github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480
+	github.com/golang/protobuf/v2 v2.0.0
+)
+
+replace github.com/golang/protobuf/v2 => ../../..

+ 23 - 0
cmd/protoc-gen-go/testdata/go.sum

@@ -0,0 +1,23 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480 h1:K3kcmzT/cPx8K4eprFqWF4cLZIxiOLNm+vKmNqQFCBw=
+github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480/go.mod h1:asK8yRb/+zxJTE0SbTESCku/4OjiDfbPwk4rEyIatUA=
+github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20180928181343-b3c0be4c978b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

+ 6 - 6
cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go

@@ -57,14 +57,14 @@ func init() {
 }
 
 var xxx_File_imports_fmt_m_proto_rawdesc = []byte{
-	// 104 bytes of the wire-encoded FileDescriptorProto
+	// 111 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x13, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x66, 0x6d, 0x74, 0x2f, 0x6d, 0x2e,
 	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x66, 0x6d, 0x74, 0x22, 0x03, 0x0a, 0x01, 0x4d, 0x42,
-	0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
-	0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x66, 0x6d, 0x74,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
+	0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32,
+	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, 0x6d, 0x70, 0x6f,
+	0x72, 0x74, 0x73, 0x2f, 0x66, 0x6d, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_fmt_m_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_fmt_m_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/fmt/m.proto

@@ -4,5 +4,5 @@
 
 syntax = "proto3";
 package fmt;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/fmt";
 message M {}

+ 7 - 6
cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go

@@ -130,18 +130,19 @@ func init() {
 }
 
 var xxx_File_imports_test_a_1_m1_proto_rawdesc = []byte{
-	// 174 bytes of the wire-encoded FileDescriptorProto
+	// 181 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
 	0x5f, 0x31, 0x2f, 0x6d, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, 0x73,
 	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x31, 0x22, 0x22, 0x0a, 0x04, 0x4d, 0x31, 0x5f,
 	0x31, 0x12, 0x1a, 0x0a, 0x02, 0x6d, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e,
 	0x74, 0x65, 0x73, 0x74, 0x2e, 0x61, 0x2e, 0x4d, 0x31, 0x52, 0x02, 0x6d, 0x31, 0x2a, 0x11, 0x0a,
 	0x02, 0x45, 0x31, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x31, 0x5f, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00,
-	0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67,
-	0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65,
-	0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67,
+	0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76,
+	0x32, 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, 0x6d, 0x70,
+	0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x62, 0x06, 0x70,
+	0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_a_1_m1_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_a_1_m1_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_a_1/m1.proto

@@ -4,7 +4,7 @@
 
 syntax = "proto3";
 package test.a;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1";
 
 message M1 {}
 

+ 6 - 6
cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go

@@ -57,15 +57,15 @@ func init() {
 }
 
 var xxx_File_imports_test_a_1_m2_proto_rawdesc = []byte{
-	// 119 bytes of the wire-encoded FileDescriptorProto
+	// 126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
 	0x5f, 0x31, 0x2f, 0x6d, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, 0x73,
-	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x32, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74,
+	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x32, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74,
 	0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70,
-	0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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,
-	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x62,
-	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65,
+	0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_a_1_m2_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_a_1_m2_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_a_1/m2.proto

@@ -4,5 +4,5 @@
 
 syntax = "proto3";
 package test.a;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1";
 message M2 {}

+ 6 - 6
cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go

@@ -57,15 +57,15 @@ func init() {
 }
 
 var xxx_File_imports_test_a_2_m3_proto_rawdesc = []byte{
-	// 119 bytes of the wire-encoded FileDescriptorProto
+	// 126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
 	0x5f, 0x32, 0x2f, 0x6d, 0x33, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, 0x73,
-	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x33, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74,
+	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x33, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74,
 	0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70,
-	0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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,
-	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x5f, 0x32, 0x62,
-	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65,
+	0x73, 0x74, 0x5f, 0x61, 0x5f, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_a_2_m3_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_a_2_m3_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_a_2/m3.proto

@@ -4,5 +4,5 @@
 
 syntax = "proto3";
 package test.a;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_2";
 message M3 {}

+ 6 - 6
cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go

@@ -57,15 +57,15 @@ func init() {
 }
 
 var xxx_File_imports_test_a_2_m4_proto_rawdesc = []byte{
-	// 119 bytes of the wire-encoded FileDescriptorProto
+	// 126 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
 	0x5f, 0x32, 0x2f, 0x6d, 0x34, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, 0x73,
-	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x34, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74,
+	0x74, 0x2e, 0x61, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x34, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74,
 	0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70,
-	0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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,
-	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x5f, 0x32, 0x62,
-	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65,
+	0x73, 0x74, 0x5f, 0x61, 0x5f, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_a_2_m4_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_a_2_m4_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_a_2/m4.proto

@@ -4,5 +4,5 @@
 
 syntax = "proto3";
 package test.a;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_2";
 message M4 {}

+ 7 - 7
cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go

@@ -57,16 +57,16 @@ func init() {
 }
 
 var xxx_File_imports_test_b_1_m1_proto_rawdesc = []byte{
-	// 130 bytes of the wire-encoded FileDescriptorProto
+	// 137 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62,
 	0x5f, 0x31, 0x2f, 0x6d, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x74, 0x65, 0x73,
 	0x74, 0x2e, 0x62, 0x2e, 0x70, 0x61, 0x72, 0x74, 0x31, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x31, 0x42,
-	0x49, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
-	0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73,
-	0x74, 0x5f, 0x62, 0x5f, 0x31, 0x3b, 0x62, 0x65, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
-	0x6f, 0x33,
+	0x50, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
+	0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32,
+	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, 0x6d, 0x70, 0x6f,
+	0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x5f, 0x31, 0x3b, 0x62, 0x65, 0x74,
+	0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_b_1_m1_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_b_1_m1_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_b_1/m1.proto

@@ -4,5 +4,5 @@
 
 syntax = "proto3";
 package test.b.part1;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_b_1;beta";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_b_1;beta";
 message M1 {}

+ 7 - 7
cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go

@@ -57,16 +57,16 @@ func init() {
 }
 
 var xxx_File_imports_test_b_1_m2_proto_rawdesc = []byte{
-	// 130 bytes of the wire-encoded FileDescriptorProto
+	// 137 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62,
 	0x5f, 0x31, 0x2f, 0x6d, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x74, 0x65, 0x73,
 	0x74, 0x2e, 0x62, 0x2e, 0x70, 0x61, 0x72, 0x74, 0x32, 0x22, 0x04, 0x0a, 0x02, 0x4d, 0x32, 0x42,
-	0x49, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
-	0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73,
-	0x74, 0x5f, 0x62, 0x5f, 0x31, 0x3b, 0x62, 0x65, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
-	0x6f, 0x33,
+	0x50, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f,
+	0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x32,
+	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, 0x6d, 0x70, 0x6f,
+	0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x5f, 0x31, 0x3b, 0x62, 0x65, 0x74,
+	0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_b_1_m2_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_b_1_m2_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_b_1/m2.proto

@@ -4,5 +4,5 @@
 
 syntax = "proto3";
 package test.b.part2;
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_b_1;beta";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_b_1;beta";
 message M2 {}

+ 6 - 6
cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go

@@ -6,7 +6,7 @@ package imports
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoapi "github.com/golang/protobuf/protoapi"
-	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+	test_a_1 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -66,18 +66,18 @@ func init() {
 }
 
 var xxx_File_imports_test_import_a1m1_proto_rawdesc = []byte{
-	// 168 bytes of the wire-encoded FileDescriptorProto
+	// 175 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1e, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69,
 	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x61, 0x31, 0x6d, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
 	0x12, 0x04, 0x74, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f,
 	0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x2f, 0x6d, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74,
 	0x6f, 0x22, 0x20, 0x0a, 0x04, 0x41, 0x31, 0x4d, 0x31, 0x12, 0x18, 0x0a, 0x01, 0x66, 0x18, 0x01,
 	0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x61, 0x2e, 0x4d, 0x31,
-	0x52, 0x01, 0x66, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
+	0x52, 0x01, 0x66, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
 	0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
-	0x66, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x66, 0x2f, 0x76, 0x32, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_import_a1m1_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_import_a1m1_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_import_a1m1.proto

@@ -6,7 +6,7 @@ syntax = "proto3";
 
 package test;
 
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports";
 
 import "imports/test_a_1/m1.proto";
 

+ 6 - 6
cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go

@@ -6,7 +6,7 @@ package imports
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoapi "github.com/golang/protobuf/protoapi"
-	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+	test_a_1 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -66,18 +66,18 @@ func init() {
 }
 
 var xxx_File_imports_test_import_a1m2_proto_rawdesc = []byte{
-	// 168 bytes of the wire-encoded FileDescriptorProto
+	// 175 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1e, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69,
 	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x61, 0x31, 0x6d, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
 	0x12, 0x04, 0x74, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f,
 	0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x5f, 0x31, 0x2f, 0x6d, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74,
 	0x6f, 0x22, 0x20, 0x0a, 0x04, 0x41, 0x31, 0x4d, 0x32, 0x12, 0x18, 0x0a, 0x01, 0x66, 0x18, 0x01,
 	0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x61, 0x2e, 0x4d, 0x32,
-	0x52, 0x01, 0x66, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
+	0x52, 0x01, 0x66, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
 	0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
-	0x66, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x66, 0x2f, 0x76, 0x32, 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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_import_a1m2_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_import_a1m2_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_import_a1m2.proto

@@ -6,7 +6,7 @@ syntax = "proto3";
 
 package test;
 
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports";
 
 import "imports/test_a_1/m2.proto";
 

+ 9 - 9
cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go

@@ -6,10 +6,10 @@ package imports
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoapi "github.com/golang/protobuf/protoapi"
-	fmt "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt"
-	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
-	_ "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2"
-	test_b_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_b_1"
+	fmt "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/fmt"
+	test_a_1 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1"
+	_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_2"
+	test_b_1 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_b_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
@@ -101,7 +101,7 @@ func init() {
 }
 
 var xxx_File_imports_test_import_all_proto_rawdesc = []byte{
-	// 455 bytes of the wire-encoded FileDescriptorProto
+	// 462 bytes of the wire-encoded FileDescriptorProto
 	0x0a, 0x1d, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x69,
 	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
 	0x04, 0x74, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2f, 0x74,
@@ -126,11 +126,11 @@ var xxx_File_imports_test_import_all_proto_rawdesc = []byte{
 	0x0b, 0x32, 0x10, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x62, 0x2e, 0x70, 0x61, 0x72, 0x74, 0x32,
 	0x2e, 0x4d, 0x32, 0x52, 0x03, 0x62, 0x6d, 0x32, 0x12, 0x18, 0x0a, 0x03, 0x66, 0x6d, 0x74, 0x18,
 	0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x66, 0x6d, 0x74, 0x2e, 0x4d, 0x52, 0x03, 0x66,
-	0x6d, 0x74, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
+	0x6d, 0x74, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
 	0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
-	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, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x62,
-	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x2f, 0x76, 0x32, 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,
+	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var xxx_File_imports_test_import_all_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_imports_test_import_all_proto_rawdesc)

+ 1 - 1
cmd/protoc-gen-go/testdata/imports/test_import_all.proto

@@ -6,7 +6,7 @@ syntax = "proto3";
 
 package test;
 
-option go_package = "github.com/golang/protobuf/protoc-gen-go/testdata/imports";
+option go_package = "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports";
 
 // test_a_1/m*.proto are in the same Go package and proto package.
 // test_a_*/*.proto are in different Go packages, but the same proto package.

+ 0 - 2
go.mod

@@ -3,6 +3,4 @@ module github.com/golang/protobuf/v2
 require (
 	github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480
 	github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783
-	google.golang.org/genproto v0.0.0-20180831171423-11092d34479b // indirect
-	google.golang.org/grpc v1.19.0
 )

+ 0 - 21
go.sum

@@ -1,35 +1,14 @@
-cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
-github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
-github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
-github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
-github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.2.1-0.20181127190454-8d0c54c12466/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
 github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480 h1:K3kcmzT/cPx8K4eprFqWF4cLZIxiOLNm+vKmNqQFCBw=
 github.com/golang/protobuf v1.2.1-0.20190228215449-22c36ed95480/go.mod h1:asK8yRb/+zxJTE0SbTESCku/4OjiDfbPwk4rEyIatUA=
 github.com/golang/protobuf/v2 v2.0.0-20181127193627-d7e97bc71bcb/go.mod h1:MgUD+N3FwzDmj2CdMsT5ap7K7jx+c9cQDQ7fVhmH+Xw=
 github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783 h1:wVZ6laEGf86tNDTpR5mxFyFIclJJiXCxuJhcQKnsOHk=
 github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
-golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
-golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 h1:dgd4x4kJt7G4k4m93AYLzM8Ni6h2qLTfh9n9vXJT3/0=
 golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
-golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/tools v0.0.0-20180904205237-0aa4b8830f48/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20180928181343-b3c0be4c978b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
-google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
-google.golang.org/genproto v0.0.0-20180831171423-11092d34479b h1:lohp5blsw53GBXtLyLNaTXPXS9pJ1tiTw61ZHUoE9Qw=
 google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
-google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
-google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

+ 9 - 8
integration_test.go

@@ -57,20 +57,21 @@ func Test(t *testing.T) {
 
 	for _, v := range golangVersions {
 		t.Run("Go"+v, func(t *testing.T) {
-			runGo := func(label string, args ...string) {
+			runGo := func(label, workDir string, args ...string) {
 				args[0] += v
 				t.Run(label, func(t *testing.T) {
 					t.Parallel()
-					mustRunCommand(t, filepath.Join(goPath, "src", modulePath), args...)
+					mustRunCommand(t, workDir, args...)
 				})
 			}
-			// TODO: "go build" does not descend into testdata,
-			// which means that generated .pb.go files are not being built.
-			runGo("Build", "go", "build", "./...")
-			runGo("TestNormal", "go", "test", "-race", "./...")
-			runGo("TestPureGo", "go", "test", "-race", "-tags", "purego", "./...")
+			workDir := filepath.Join(goPath, "src", modulePath)
+			runGo("Build", workDir, "go", "build", "./...")
+			runGo("TestNormal", workDir, "go", "test", "-race", "./...")
+			runGo("TestPureGo", workDir, "go", "test", "-race", "-tags", "purego", "./...")
 			if v == golangLatest {
-				runGo("TestLegacy", "go", "test", "-race", "-tags", "proto1_legacy", "./...")
+				runGo("TestProto1Legacy", workDir, "go", "test", "-race", "-tags", "proto1_legacy", "./...")
+				runGo("TestProtocGenGo", "cmd/protoc-gen-go/testdata", "go", "test")
+				runGo("TestProtocGenGoGRPC", "cmd/protoc-gen-go-grpc/testdata", "go", "test")
 			}
 		})
 	}

+ 67 - 27
internal/cmd/generate-protos/main.go

@@ -9,12 +9,14 @@ package main
 import (
 	"flag"
 	"fmt"
+	"go/format"
 	"io/ioutil"
 	"os"
 	"os/exec"
 	"path"
 	"path/filepath"
 	"regexp"
+	"sort"
 	"strings"
 
 	gengogrpc "github.com/golang/protobuf/v2/cmd/protoc-gen-go-grpc/internal_gengogrpc"
@@ -27,13 +29,19 @@ func init() {
 	// When the environment variable RUN_AS_PROTOC_PLUGIN is set,
 	// we skip running main and instead act as a protoc plugin.
 	// This allows the binary to pass itself to protoc.
-	if os.Getenv("RUN_AS_PROTOC_PLUGIN") != "" {
+	if plugins := os.Getenv("RUN_AS_PROTOC_PLUGIN"); plugins != "" {
 		protogen.Run(nil, func(gen *protogen.Plugin) error {
-			for _, file := range gen.Files {
-				if file.Generate {
-					gengo.GenerateFile(gen, file)
-					gengogrpc.GenerateFile(gen, file)
-					generateDescriptorFields(gen, file)
+			for _, plugin := range strings.Split(plugins, ",") {
+				for _, file := range gen.Files {
+					if file.Generate {
+						switch plugin {
+						case "go":
+							gengo.GenerateFile(gen, file)
+							generateDescriptorFields(gen, file)
+						case "gogrpc":
+							gengogrpc.GenerateFile(gen, file)
+						}
+					}
 				}
 			}
 			return nil
@@ -43,9 +51,10 @@ func init() {
 }
 
 var (
-	run       bool
-	protoRoot string
-	repoRoot  string
+	run        bool
+	protoRoot  string
+	repoRoot   string
+	modulePath string
 
 	generatedPreamble = []string{
 		"// Copyright 2019 The Go Authors. All rights reserved.",
@@ -70,6 +79,13 @@ func main() {
 	check(err)
 	repoRoot = strings.TrimSpace(string(out))
 
+	// Determine the module path.
+	cmd := exec.Command("go", "list", "-m", "-f", "{{.Path}}")
+	cmd.Dir = repoRoot
+	out, err = cmd.CombinedOutput()
+	check(err)
+	modulePath = strings.TrimSpace(string(out))
+
 	generateLocalProtos()
 	generateRemoteProtos()
 }
@@ -82,16 +98,19 @@ func generateLocalProtos() {
 	// Generate all local proto files (except version-locked files).
 	dirs := []struct {
 		path        string
+		grpcPlugin  bool
 		annotateFor map[string]bool
 	}{
-		{"cmd/protoc-gen-go/testdata", map[string]bool{"annotations/annotations.proto": true}},
-		{"cmd/protoc-gen-go-grpc/testdata", nil},
-		{"internal/testprotos", nil},
-		{"encoding/testprotos", nil},
-		{"reflect/protoregistry/testprotos", nil},
+		{path: "cmd/protoc-gen-go/testdata", annotateFor: map[string]bool{"annotations/annotations.proto": true}},
+		{path: "cmd/protoc-gen-go-grpc/testdata", grpcPlugin: true},
+		{path: "internal/testprotos"},
+		{path: "encoding/testprotos"},
+		{path: "reflect/protoregistry/testprotos"},
 	}
 	semVerRx := regexp.MustCompile(`v[0-9]+\.[0-9]+\.[0-9]+`)
 	for _, d := range dirs {
+		subDirs := map[string]bool{}
+
 		dstDir := filepath.Join(tmpDir, filepath.FromSlash(d.path))
 		check(os.MkdirAll(dstDir, 0775))
 
@@ -102,6 +121,7 @@ func generateLocalProtos() {
 			}
 			relPath, err := filepath.Rel(srcDir, srcPath)
 			check(err)
+			subDirs[filepath.Dir(relPath)] = true
 
 			// Emit a .meta file for certain files.
 			var opts string
@@ -109,9 +129,36 @@ func generateLocalProtos() {
 				opts = ",annotate_code"
 			}
 
-			protoc("-I"+filepath.Join(protoRoot, "src"), "-I"+srcDir, "--go_out=paths=source_relative"+opts+":"+dstDir, relPath)
+			// Determine which set of plugins to use.
+			plugins := "go"
+			if d.grpcPlugin {
+				plugins += ",gogrpc"
+			}
+
+			protoc(plugins, "-I"+filepath.Join(protoRoot, "src"), "-I"+srcDir, "--go_out=paths=source_relative"+opts+":"+dstDir, relPath)
 			return nil
 		})
+
+		// For directories in testdata, generate a test that links in all
+		// generated packages to ensure that it builds and initializes properly.
+		// This is done because "go build ./..." does not build sub-packages
+		// under testdata.
+		if filepath.Base(d.path) == "testdata" {
+			var imports []string
+			for sd := range subDirs {
+				imports = append(imports, fmt.Sprintf("_ %q", path.Join(modulePath, d.path, filepath.ToSlash(sd))))
+			}
+			sort.Strings(imports)
+
+			s := strings.Join(append(generatedPreamble, []string{
+				"package main",
+				"",
+				"import (" + strings.Join(imports, "\n") + ")",
+			}...), "\n")
+			b, err := format.Source([]byte(s))
+			check(err)
+			check(ioutil.WriteFile(filepath.Join(tmpDir, filepath.FromSlash(d.path+"/gen_test.go")), b, 0664))
+		}
 	}
 
 	syncOutput(repoRoot, tmpDir)
@@ -139,23 +186,16 @@ func generateRemoteProtos() {
 		{"src", "google/protobuf/compiler/plugin.proto"},
 	}
 	for _, f := range files {
-		protoc("-I"+filepath.Join(protoRoot, f.prefix), "--go_out="+tmpDir, f.path)
+		protoc("go", "-I"+filepath.Join(protoRoot, f.prefix), "--go_out="+tmpDir, f.path)
 	}
 
-	// Determine the module path.
-	cmd := exec.Command("go", "list", "-m", "-f", "{{.Path}}")
-	cmd.Dir = repoRoot
-	out, err := cmd.CombinedOutput()
-	check(err)
-	modulePath := strings.TrimSpace(string(out))
-
 	syncOutput(repoRoot, filepath.Join(tmpDir, modulePath))
 }
 
-func protoc(args ...string) {
+func protoc(plugins string, args ...string) {
 	cmd := exec.Command("protoc", "--plugin=protoc-gen-go="+os.Args[0])
 	cmd.Args = append(cmd.Args, args...)
-	cmd.Env = append(os.Environ(), "RUN_AS_PROTOC_PLUGIN=1")
+	cmd.Env = append(os.Environ(), "RUN_AS_PROTOC_PLUGIN="+plugins)
 	cmd.Env = append(cmd.Env, "PROTOC_GEN_GO_ENABLE_REFLECT=1")
 	out, err := cmd.CombinedOutput()
 	if err != nil {
@@ -170,8 +210,8 @@ func generateDescriptorFields(gen *protogen.Plugin, file *protogen.File) {
 		return
 	}
 
-	const importPath = "github.com/golang/protobuf/v2/internal/descfield"
-	g := gen.NewGeneratedFile(importPath+"/field_gen.go", importPath)
+	importPath := modulePath + "/internal/descfield"
+	g := gen.NewGeneratedFile(importPath+"/field_gen.go", protogen.GoImportPath(importPath))
 	for _, s := range generatedPreamble {
 		g.P(s)
 	}

+ 0 - 217
internal/testprotos/test/test_grpc.pb.go

@@ -1,217 +0,0 @@
-// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
-
-package test
-
-import (
-	context "context"
-	grpc "google.golang.org/grpc"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// TestServiceClient is the client API for TestService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type TestServiceClient interface {
-	Foo(ctx context.Context, in *FooRequest, opts ...grpc.CallOption) (*FooResponse, error)
-	TestStream(ctx context.Context, opts ...grpc.CallOption) (TestService_TestStreamClient, error)
-}
-
-type testServiceClient struct {
-	cc *grpc.ClientConn
-}
-
-func NewTestServiceClient(cc *grpc.ClientConn) TestServiceClient {
-	return &testServiceClient{cc}
-}
-
-func (c *testServiceClient) Foo(ctx context.Context, in *FooRequest, opts ...grpc.CallOption) (*FooResponse, error) {
-	out := new(FooResponse)
-	err := c.cc.Invoke(ctx, "/goproto.proto.test.TestService/Foo", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *testServiceClient) TestStream(ctx context.Context, opts ...grpc.CallOption) (TestService_TestStreamClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[0], "/goproto.proto.test.TestService/TestStream", opts...)
-	if err != nil {
-		return nil, err
-	}
-	x := &testServiceTestStreamClient{stream}
-	return x, nil
-}
-
-type TestService_TestStreamClient interface {
-	Send(*FooRequest) error
-	Recv() (*FooResponse, error)
-	grpc.ClientStream
-}
-
-type testServiceTestStreamClient struct {
-	grpc.ClientStream
-}
-
-func (x *testServiceTestStreamClient) Send(m *FooRequest) error {
-	return x.ClientStream.SendMsg(m)
-}
-
-func (x *testServiceTestStreamClient) Recv() (*FooResponse, error) {
-	m := new(FooResponse)
-	if err := x.ClientStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-// TestServiceServer is the server API for TestService service.
-type TestServiceServer interface {
-	Foo(context.Context, *FooRequest) (*FooResponse, error)
-	TestStream(TestService_TestStreamServer) error
-}
-
-func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) {
-	s.RegisterService(&_TestService_serviceDesc, srv)
-}
-
-func _TestService_Foo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(FooRequest)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(TestServiceServer).Foo(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/goproto.proto.test.TestService/Foo",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(TestServiceServer).Foo(ctx, req.(*FooRequest))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _TestService_TestStream_Handler(srv interface{}, stream grpc.ServerStream) error {
-	return srv.(TestServiceServer).TestStream(&testServiceTestStreamServer{stream})
-}
-
-type TestService_TestStreamServer interface {
-	Send(*FooResponse) error
-	Recv() (*FooRequest, error)
-	grpc.ServerStream
-}
-
-type testServiceTestStreamServer struct {
-	grpc.ServerStream
-}
-
-func (x *testServiceTestStreamServer) Send(m *FooResponse) error {
-	return x.ServerStream.SendMsg(m)
-}
-
-func (x *testServiceTestStreamServer) Recv() (*FooRequest, error) {
-	m := new(FooRequest)
-	if err := x.ServerStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-var _TestService_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "goproto.proto.test.TestService",
-	HandlerType: (*TestServiceServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "Foo",
-			Handler:    _TestService_Foo_Handler,
-		},
-	},
-	Streams: []grpc.StreamDesc{
-		{
-			StreamName:    "TestStream",
-			Handler:       _TestService_TestStream_Handler,
-			ServerStreams: true,
-			ClientStreams: true,
-		},
-	},
-	Metadata: "test/test.proto",
-}
-
-// TestDeprecatedServiceClient is the client API for TestDeprecatedService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-//
-// Deprecated: Do not use.
-type TestDeprecatedServiceClient interface {
-	Deprecated(ctx context.Context, in *TestDeprecatedMessage, opts ...grpc.CallOption) (*TestDeprecatedMessage, error)
-}
-
-type testDeprecatedServiceClient struct {
-	cc *grpc.ClientConn
-}
-
-// Deprecated: Do not use.
-func NewTestDeprecatedServiceClient(cc *grpc.ClientConn) TestDeprecatedServiceClient {
-	return &testDeprecatedServiceClient{cc}
-}
-
-// Deprecated: Do not use.
-func (c *testDeprecatedServiceClient) Deprecated(ctx context.Context, in *TestDeprecatedMessage, opts ...grpc.CallOption) (*TestDeprecatedMessage, error) {
-	out := new(TestDeprecatedMessage)
-	err := c.cc.Invoke(ctx, "/goproto.proto.test.TestDeprecatedService/Deprecated", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// TestDeprecatedServiceServer is the server API for TestDeprecatedService service.
-//
-// Deprecated: Do not use.
-type TestDeprecatedServiceServer interface {
-	Deprecated(context.Context, *TestDeprecatedMessage) (*TestDeprecatedMessage, error)
-}
-
-// Deprecated: Do not use.
-func RegisterTestDeprecatedServiceServer(s *grpc.Server, srv TestDeprecatedServiceServer) {
-	s.RegisterService(&_TestDeprecatedService_serviceDesc, srv)
-}
-
-func _TestDeprecatedService_Deprecated_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(TestDeprecatedMessage)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(TestDeprecatedServiceServer).Deprecated(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/goproto.proto.test.TestDeprecatedService/Deprecated",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(TestDeprecatedServiceServer).Deprecated(ctx, req.(*TestDeprecatedMessage))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-var _TestDeprecatedService_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "goproto.proto.test.TestDeprecatedService",
-	HandlerType: (*TestDeprecatedServiceServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "Deprecated",
-			Handler:    _TestDeprecatedService_Deprecated_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "test/test.proto",
-}

+ 1 - 1
regenerate.bash

@@ -4,5 +4,5 @@
 # license that can be found in the LICENSE file.
 
 cd "$(git rev-parse --show-toplevel)"
-go test -v -mod=vendor -timeout=60m integration_test.go "$@" -regenerate
+go test -v -mod=vendor -timeout=60m -count=1 integration_test.go "$@" -regenerate
 exit $?

+ 1 - 1
test.bash

@@ -4,5 +4,5 @@
 # license that can be found in the LICENSE file.
 
 cd "$(git rev-parse --show-toplevel)"
-go test -v -mod=vendor -timeout=60m integration_test.go "$@"
+go test -v -mod=vendor -timeout=60m -count=1 integration_test.go "$@"
 exit $?