Damien Neil | 220c202 | 2018-08-15 11:24:18 -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 ( |
| 10 | "strings" |
| 11 | |
| 12 | "google.golang.org/proto/protogen" |
| 13 | ) |
| 14 | |
| 15 | func main() { |
| 16 | protogen.Run(func(gen *protogen.Plugin) error { |
| 17 | for _, f := range gen.Files { |
| 18 | if !f.Generate { |
| 19 | continue |
| 20 | } |
| 21 | genFile(gen, f) |
| 22 | } |
| 23 | return nil |
| 24 | }) |
| 25 | } |
| 26 | |
| 27 | func genFile(gen *protogen.Plugin, f *protogen.File) { |
| 28 | g := gen.NewGeneratedFile(strings.TrimSuffix(f.Desc.GetName(), ".proto") + ".pb.go") |
| 29 | g.P("// Code generated by protoc-gen-go. DO NOT EDIT.") |
| 30 | g.P("// source: ", f.Desc.GetName()) |
| 31 | g.P() |
| 32 | g.P("package TODO") |
| 33 | |
| 34 | // TODO: Everything. |
| 35 | } |