Explorar o código

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>
Damien Neil %!s(int64=7) %!d(string=hai) anos
pai
achega
1adaec9cae

+ 3 - 4
cmd/protoc-gen-go/main.go → 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 generatedCodeVersion = 2
 
 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", "", "")

+ 5 - 1
cmd/protoc-gen-go/oneof.go → 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"

+ 1 - 1
cmd/protoc-gen-go/options.go → 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"

+ 15 - 0
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()
+}