blob: b55d64244492b8e7ac18dfe437d62b831fdb2a03 [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 Neil1fa8ab02018-09-27 15:51:05 -070018 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 Neil9c420a62018-09-27 15:26:33 -070026 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 Neil1fa8ab02018-09-27 15:51:05 -070030 if *importPrefix != "" {
31 return errors.New("protoc-gen-go: import_prefix is not supported")
32 }
Damien Neil9c420a62018-09-27 15:26:33 -070033 for _, f := range gen.Files {
Joe Tsai19058432019-02-27 21:46:29 -080034 if f.Generate {
35 gengo.GenerateFile(gen, f)
Damien Neil9c420a62018-09-27 15:26:33 -070036 }
Damien Neil9c420a62018-09-27 15:26:33 -070037 }
38 return nil
39 })
Damien Neil1adaec92018-09-24 13:43:03 -070040}