Damien Neil | 1adaec9 | 2018-09-24 13:43:03 -0700 | [diff] [blame] | 1 | // 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. |
| 7 | package main |
| 8 | |
| 9 | import ( |
Damien Neil | 9c420a6 | 2018-09-27 15:26:33 -0700 | [diff] [blame] | 10 | "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 Neil | 1adaec9 | 2018-09-24 13:43:03 -0700 | [diff] [blame] | 15 | ) |
| 16 | |
| 17 | func main() { |
Damien Neil | 1fa8ab0 | 2018-09-27 15:51:05 -0700 | [diff] [blame] | 18 | var ( |
| 19 | flags flag.FlagSet |
| 20 | plugins = flags.String("plugins", "", "deprecated option") |
| 21 | importPrefix = flags.String("import_prefix", "", "deprecated option") |
| 22 | opts = &protogen.Options{ |
| 23 | ParamFunc: flags.Set, |
| 24 | } |
| 25 | ) |
Damien Neil | 9c420a6 | 2018-09-27 15:26:33 -0700 | [diff] [blame] | 26 | protogen.Run(opts, func(gen *protogen.Plugin) error { |
| 27 | if *plugins != "" { |
| 28 | return errors.New("protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC") |
| 29 | } |
Damien Neil | 1fa8ab0 | 2018-09-27 15:51:05 -0700 | [diff] [blame] | 30 | if *importPrefix != "" { |
| 31 | return errors.New("protoc-gen-go: import_prefix is not supported") |
| 32 | } |
Damien Neil | 9c420a6 | 2018-09-27 15:26:33 -0700 | [diff] [blame] | 33 | for _, f := range gen.Files { |
Joe Tsai | 1905843 | 2019-02-27 21:46:29 -0800 | [diff] [blame] | 34 | if f.Generate { |
| 35 | gengo.GenerateFile(gen, f) |
Damien Neil | 9c420a6 | 2018-09-27 15:26:33 -0700 | [diff] [blame] | 36 | } |
Damien Neil | 9c420a6 | 2018-09-27 15:26:33 -0700 | [diff] [blame] | 37 | } |
| 38 | return nil |
| 39 | }) |
Damien Neil | 1adaec9 | 2018-09-24 13:43:03 -0700 | [diff] [blame] | 40 | } |