internal/protolegacy: add stub v1 proto package for testing purposes
The protolegacy package is a minimal version of the v1 proto package.
This allows us to use this stub version as the dependency for
internal/testprotos/legacy packages and avoid a dependency
on the real v1 proto package.
The implementation of most v1 functionality will panic if called.
This way, we know if we the v2 code depends on one of those
unimplemented functions.
Updates golang/protobuf#962
Change-Id: I20b4091706fd456e4b01ae0931cce30a872639b0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/199297
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/legacy/legacy.proto b/internal/testprotos/legacy/legacy.proto
index 631368d..d12c312 100644
--- a/internal/testprotos/legacy/legacy.proto
+++ b/internal/testprotos/legacy/legacy.proto
@@ -15,6 +15,10 @@
//
// The specific version of protoc-gen-go used is encoded in the file path:
// $NAME.$VERSION-$COMMIT_DATE-$COMMIT_HASH/test.proto
+//
+// To avoid a dependency on the v1 module, we perform the following
+// import path replacement to all generated .pb.go files:
+// "github.com/golang/protobuf/proto" => "google.golang.org/protobuf/internal/protolegacy"
// The oldest supported version of protoc-gen-go is 2fc053c5,
// which finished adding descriptor methods to all protobuf types.