mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2024-12-27 15:26:51 +00:00
b0a944684d
Apply go1.19 gofmt to non-generated files. Generated .pb.go files are created by generate.bash using Go 1.18, so leave them unchanged for now. Change-Id: Ied36c83cf99704988d059bf0412e677f0fbc71b0 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418676 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Lasse Folger <lassefolger@google.com>
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
// 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 Go code for
|
|
// both proto2 and proto3 versions of the protocol buffer language.
|
|
//
|
|
// For more information about the usage of this plugin, see:
|
|
//
|
|
// https://developers.google.com/protocol-buffers/docs/reference/go-generated
|
|
package main
|
|
|
|
import (
|
|
"errors"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
gengo "google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo"
|
|
"google.golang.org/protobuf/compiler/protogen"
|
|
"google.golang.org/protobuf/internal/version"
|
|
)
|
|
|
|
const genGoDocURL = "https://developers.google.com/protocol-buffers/docs/reference/go-generated"
|
|
const grpcDocURL = "https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code"
|
|
|
|
func main() {
|
|
if len(os.Args) == 2 && os.Args[1] == "--version" {
|
|
fmt.Fprintf(os.Stdout, "%v %v\n", filepath.Base(os.Args[0]), version.String())
|
|
os.Exit(0)
|
|
}
|
|
if len(os.Args) == 2 && os.Args[1] == "--help" {
|
|
fmt.Fprintf(os.Stdout, "See "+genGoDocURL+" for usage information.\n")
|
|
os.Exit(0)
|
|
}
|
|
|
|
var (
|
|
flags flag.FlagSet
|
|
plugins = flags.String("plugins", "", "deprecated option")
|
|
)
|
|
protogen.Options{
|
|
ParamFunc: flags.Set,
|
|
}.Run(func(gen *protogen.Plugin) error {
|
|
if *plugins != "" {
|
|
return errors.New("protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC\n\n" +
|
|
"See " + grpcDocURL + " for more information.")
|
|
}
|
|
for _, f := range gen.Files {
|
|
if f.Generate {
|
|
gengo.GenerateFile(gen, f)
|
|
}
|
|
}
|
|
gen.SupportedFeatures = gengo.SupportedFeatures
|
|
return nil
|
|
})
|
|
}
|