internal/filedesc: print warnings on registration conflicts

Rather than panicking at init time due to registration failures,
print a warning to stderr. Historically, the Go protobuf implementation
has not been strict about registration conflicts, which has led users
to unknowningly tolerating conflicts that may or may not expose
themselvs as a bug.

Registration conlicts now produce a log message:
<<<
2019/07/17 17:36:42 WARNING: proto: file "path/to/example.proto" is already registered
	previously from: "example.com/company/example_proto"
	currently from:  "example.com/user/example_proto"
A future release will panic on registration conflicts.

>>>

Change-Id: I2d583f04977c8bc8cb6bbd33d239277690bbec54
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186181
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/filedesc/build.go b/internal/filedesc/build.go
index 427e26e..52cbdf1 100644
--- a/internal/filedesc/build.go
+++ b/internal/filedesc/build.go
@@ -6,6 +6,8 @@
 package filedesc
 
 import (
+	"log"
+
 	"google.golang.org/protobuf/internal/encoding/wire"
 	"google.golang.org/protobuf/internal/fieldnum"
 	"google.golang.org/protobuf/reflect/protoreflect"
@@ -105,7 +107,7 @@
 	out.Services = fd.allServices
 
 	if err := db.FileRegistry.Register(fd); err != nil {
-		panic(err)
+		CheckRegistryError(err)
 	}
 	return out
 }
@@ -150,3 +152,13 @@
 		}
 	}
 }
+
+// CheckRegistryError handles registration errors.
+// It is a variable so that its behavior can be replaced in another source file.
+var CheckRegistryError = func(err error) {
+	log.Printf(""+
+		"WARNING: %v\n"+
+		"A future release will panic on registration conflicts.\n"+
+		// TODO: Add a URL pointing to documentation on how to resolve conflicts.
+		"\n", err)
+}