Debian Codegraph @

README.md

raw symbols SCIP
1 # protobuild
2
3 [![Build Status](https://github.com/containerd/protobuild/workflows/CI/badge.svg)](https://github.com/containerd/protobuild/actions?query=workflow%3ACI)
4 [![Go Report Card](https://goreportcard.com/badge/github.com/containerd/protobuild)](https://goreportcard.com/report/github.com/containerd/protobuild)
5
6 Build protobufs in Go, easily.
7
8 `protobuild` works by scanning the go package in a project and emitting correct
9 `protoc` commands, configured with the plugins, packages and details of your
10 choice.
11
12 The main benefit is that it makes it much easier to consume external types from
13 vendored projects. By integrating the protoc include paths with Go's vendoring
14 and GOPATH, builds are much easier to keep consistent across a project.
15
16 This comes from experience with generating protobufs with `go generate` in
17 swarmkit and the tool used with containerd. It should replace both.
18
19 ## Status
20
21 Very early stages.
22
23 ## Installation
24
25 To ensure easy use with builds, we'll try to support `go get`. Install with the
26 following command:
27
28 ```
29 go get -u github.com/containerd/protobuild
30 ```
31
32 ## Usage
33
34 Protobuild works by providing a list of Go packages in which to build the
35 protobufs. To get started with a project, you must do the following:
36
37 1. Create a `Protobuild.toml` file in the root of your Go project. Use the
38 [example](Protobuild.toml) as a starting point.
39
40 2. Make sure that the packages where you want your protobuf files have a Go
41 file in place. Usually, adding a `doc.go` file is sufficient. A package for
42 protobuf should look like this:
43
44 ```
45 foo.proto
46 doc.go
47 ```
48
49 Where the contents of `doc.go` will have a package declaration in it. See
50 the [example](examples/foo/doc.go) for details. Make sure the package name
51 corresponds to what is in the `go_package` option.
52
53 3. Run the `protobuild` command:
54 ```
55 go list ./... | grep -v vendor | xargs protobuild
56 ```
57
58 ## Version Compatibility
59
60 Originally protoc-gen-go was supporting gRPC through its plugins mechanism.
61 [However gRPC support is later extracted as protoc-gen-go-gprc binary](https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#user-content-v1.20-grpc-support).
62
63 To use protoc-gen-go and protoc-gen-go-grpc. Please specify `version = "2"` and
64 both code generators instead of `plugins` like below.
65
66 ```
67 version = "2"
68 generators = ["go", "go-grpc"]
69 ```
70
71 ## Project details
72
73 protobuild is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE).
74 As a containerd sub-project, you will find the:
75 * [Project governance](https://github.com/containerd/project/blob/master/GOVERNANCE.md),
76 * [Maintainers](https://github.com/containerd/project/blob/master/MAINTAINERS),
77 * and [Contributing guidelines](https://github.com/containerd/project/blob/master/CONTRIBUTING.md)
78
79 information in our [`containerd/project`](https://github.com/containerd/project) repository.