cmd/protoc-gen-go: factor out internals into a new package

To permit the api-v1 branch to import the protoc-gen-go internals, move
them into a quasi-internal package.

Change-Id: I64e50ee299b99da1f648f7abb6cd0347a13e06e3
Reviewed-on: https://go-review.googlesource.com/137035
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
similarity index 99%
rename from cmd/protoc-gen-go/main.go
rename to cmd/protoc-gen-go/internal_gengo/main.go
index f10b7fc..518f427 100644
--- a/cmd/protoc-gen-go/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// The protoc-gen-go binary is a protoc plugin to generate a Go protocol
-// buffer package.
-package main
+// Package internal_gengo is internal to the protobuf module.
+package internal_gengo
 
 import (
 	"bytes"
@@ -32,7 +31,7 @@
 
 const protoPackage = "github.com/golang/protobuf/proto"
 
-func main() {
+func Main() {
 	var flags flag.FlagSet
 	// TODO: Decide what to do for backwards compatibility with plugins=grpc.
 	flags.String("plugins", "", "")
diff --git a/cmd/protoc-gen-go/oneof.go b/cmd/protoc-gen-go/internal_gengo/oneof.go
similarity index 98%
rename from cmd/protoc-gen-go/oneof.go
rename to cmd/protoc-gen-go/internal_gengo/oneof.go
index 13a1aee..f7e89fa 100644
--- a/cmd/protoc-gen-go/oneof.go
+++ b/cmd/protoc-gen-go/internal_gengo/oneof.go
@@ -1,4 +1,8 @@
-package main
+// Copyright 2018 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.
+
+package internal_gengo
 
 import (
 	"fmt"
diff --git a/cmd/protoc-gen-go/options.go b/cmd/protoc-gen-go/internal_gengo/options.go
similarity index 98%
rename from cmd/protoc-gen-go/options.go
rename to cmd/protoc-gen-go/internal_gengo/options.go
index 2690cbf..d582892 100644
--- a/cmd/protoc-gen-go/options.go
+++ b/cmd/protoc-gen-go/internal_gengo/options.go
@@ -6,7 +6,7 @@
 //
 // TODO: Replace this with the appropriate protoreflect API, once it exists.
 
-package main
+package internal_gengo
 
 import (
 	"github.com/golang/protobuf/proto"
diff --git a/cmd/protoc-gen-go/protoc-gen-go.go b/cmd/protoc-gen-go/protoc-gen-go.go
new file mode 100644
index 0000000..919e3d1
--- /dev/null
+++ b/cmd/protoc-gen-go/protoc-gen-go.go
@@ -0,0 +1,15 @@
+// Copyright 2018 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.
+
+// The protoc-gen-go binary is a protoc plugin to generate a Go protocol
+// buffer package.
+package main
+
+import (
+	"github.com/golang/protobuf/v2/cmd/protoc-gen-go/internal_gengo"
+)
+
+func main() {
+	internal_gengo.Main()
+}