blob: efd294b3bd5146493e50e21d3cba6e1ede9ee066 [file] [log] [blame]
Damien Neil1adaec92018-09-24 13:43:03 -07001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// The protoc-gen-go binary is a protoc plugin to generate a Go protocol
6// buffer package.
7package main
8
9import (
Damien Neil9c420a62018-09-27 15:26:33 -070010 "errors"
11 "flag"
12
13 gengo "github.com/golang/protobuf/v2/cmd/protoc-gen-go/internal_gengo"
14 "github.com/golang/protobuf/v2/protogen"
Damien Neil1adaec92018-09-24 13:43:03 -070015)
16
17func main() {
Damien Neil9c420a62018-09-27 15:26:33 -070018 var flags flag.FlagSet
19 plugins := flags.String("plugins", "", "deprecated option")
20 opts := &protogen.Options{
21 ParamFunc: flags.Set,
22 }
23 protogen.Run(opts, func(gen *protogen.Plugin) error {
24 if *plugins != "" {
25 return errors.New("protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC")
26 }
27 for _, f := range gen.Files {
28 if !f.Generate {
29 continue
30 }
31 filename := f.GeneratedFilenamePrefix + ".pb.go"
32 g := gen.NewGeneratedFile(filename, f.GoImportPath)
33 gengo.GenerateFile(gen, f, g)
34 }
35 return nil
36 })
Damien Neil1adaec92018-09-24 13:43:03 -070037}