protobuild

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

protobuild

Build Status Go Report Card

Build protobufs in Go, easily.

protobuild works by scanning the go package in a project and emitting correct protoc commands, configured with the plugins, packages and details of your choice.

It should work with both the default golang/protobuf and the gogo toolchain. If it doesn't, we should figure out how to get there.

The main benefit is that it makes it much easier to consume external types from vendored projects. By integrating the protoc include paths with Go's vendoring and GOPATH, builds are much easier to keep consistent across a project.

This comes from experience with generating protobufs with go generate in swarmkit and the tool used with containerd. It should replace both.

Status

Very early stages.

Installation

To ensure easy use with builds, we'll try to support go get. Install with the following command:

go get -u github.com/containerd/protobuild

Usage

Protobuild works by providing a list of Go packages in which to build the protobufs. To get started with a project, you must do the following:

  1. Create a Protobuild.toml file in the root of your Go project. Use the example as a starting point.

  2. Make sure that the packages where you want your protobuf files have a Go file in place. Usually, adding a doc.go file is sufficient. A package for protobuf should look like this:

    foo.proto
    doc.go
    

    Where the contents of doc.go will have a package declaration in it. See the example for details. Make sure the package name corresponds to what is in the go_package option.

  3. Run the protobuild command:

    go list ./... | grep -v vendor | xargs protobuild
    

TODO(stevvooe): Make this better.

Project details

protobuild is a containerd sub-project, licensed under the Apache 2.0 license. As a containerd sub-project, you will find the:

information in our containerd/project repository.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples
bar
Package bar demonstrates a protobuf package.
Package bar demonstrates a protobuf package.
foo
Package foo demonstrates a protobuf package.
Package foo demonstrates a protobuf package.
nogrpc
Package nogrpc will be generated without grpc, demonstrating the override feature.
Package nogrpc will be generated without grpc, demonstrating the override feature.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL