All Projects → pseudomuto → protokit

pseudomuto / protokit

Licence: MIT license
A starter kit for building protoc plugins. Rather than write your own, you can just use an existing one.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to protokit

protocell
Conjures up convenient OCaml types and serialization functions based on protobuf definition files
Stars: ✭ 18 (-73.91%)
Mutual labels:  protobuf, protoc, protoc-plugin
Prototool
Your Swiss Army Knife for Protocol Buffers
Stars: ✭ 4,932 (+7047.83%)
Mutual labels:  protobuf, protoc
Protobuf
A pure Elixir implementation of Google Protobuf
Stars: ✭ 442 (+540.58%)
Mutual labels:  protobuf, protoc
Protoc Jar
Protocol Buffers protobuf compiler - multi-platform executable protoc JAR and API
Stars: ✭ 103 (+49.28%)
Mutual labels:  protobuf, protoc
Buf
A new way of working with Protocol Buffers.
Stars: ✭ 3,328 (+4723.19%)
Mutual labels:  protobuf, protoc
Protoc Gen Gotemplate
📂 generic protocol generator based on golang's text/template (grpc/protobuf)
Stars: ✭ 284 (+311.59%)
Mutual labels:  protobuf, protoc
Rules protobuf
Bazel rules for building protocol buffers and gRPC services (java, c++, go, ...)
Stars: ✭ 206 (+198.55%)
Mutual labels:  protobuf, protoc
Pb And K
Kotlin Code Generator and Runtime for Protocol Buffers
Stars: ✭ 137 (+98.55%)
Mutual labels:  protobuf, protoc
Protoc Gen Doc
Documentation generator plugin for Google Protocol Buffers
Stars: ✭ 1,792 (+2497.1%)
Mutual labels:  protobuf, protoc
Protodot
transforming your .proto files into .dot files (and .svg, .png if you happen to have graphviz installed)
Stars: ✭ 107 (+55.07%)
Mutual labels:  protobuf, protoc
protoc-gen-kit
Protoc compiler for Go kit code
Stars: ✭ 17 (-75.36%)
Mutual labels:  protobuf, protoc
Protoc Jar Maven Plugin
Protocol Buffers protobuf maven plugin - based on protoc-jar multi-platform executable protoc JAR
Stars: ✭ 177 (+156.52%)
Mutual labels:  protobuf, protoc
docker-protobuf
An all-inclusive protoc Docker image
Stars: ✭ 105 (+52.17%)
Mutual labels:  protobuf, protoc
Protolock
Protocol Buffer companion tool. Track your .proto files and prevent changes to messages and services which impact API compatibility.
Stars: ✭ 394 (+471.01%)
Mutual labels:  protobuf, protoc
protopatch
protoc-gen-go patch utility
Stars: ✭ 58 (-15.94%)
Mutual labels:  protobuf, protoc
Protobuf Swift
Google ProtocolBuffers for Apple Swift
Stars: ✭ 925 (+1240.58%)
Mutual labels:  protobuf, protoc
gosproto
基于云风的sproto二进制标准上的描述文件及代码生成工具
Stars: ✭ 52 (-24.64%)
Mutual labels:  protobuf, protoc
protobuf-d
Protocol Buffers Compiler Plugin and Support Library for D
Stars: ✭ 32 (-53.62%)
Mutual labels:  protobuf, protoc
Protobuf
Protocol Buffers - Google's data interchange format
Stars: ✭ 52,305 (+75704.35%)
Mutual labels:  protobuf, protoc
Goprotowrap
A package-at-a-time wrapper for protoc, for generating Go protobuf code.
Stars: ✭ 147 (+113.04%)
Mutual labels:  protobuf, protoc

protokit

CI codecov GoDoc Go Report Card

A starter kit for building protoc-plugins. Rather than write your own, you can just use an existing one.

See the examples directory for uh...examples.

Getting Started

package main

import (
    "github.com/golang/protobuf/proto"
    "github.com/golang/protobuf/protoc-gen-go/plugin"
    "github.com/pseudomuto/protokit"
    _ "google.golang.org/genproto/googleapis/api/annotations" // Support (google.api.http) option (from google/api/annotations.proto).

    "log"
)

func main() {
    // all the heavy lifting done for you!
    if err := protokit.RunPlugin(new(plugin)); err != nil {
        log.Fatal(err)
    }
}

// plugin is an implementation of protokit.Plugin
type plugin struct{}

func (p *plugin) Generate(in *plugin_go.CodeGeneratorRequest) (*plugin_go.CodeGeneratorResponse, error) {
    descriptors := protokit.ParseCodeGenRequest(req)

    resp := new(plugin_go.CodeGeneratorResponse)

    for _, d := range descriptors {
        // TODO: YOUR WORK HERE
        fileName := // generate a file name based on d.GetName()
        content := // generate content for the output file

        resp.File = append(resp.File, &plugin_go.CodeGeneratorResponse_File{
            Name:    proto.String(fileName),
            Content: proto.String(content),
        })
    }

    return resp, nil
}

Then invoke your plugin via protoc. For example (assuming your app is called thingy):

protoc --plugin=protoc-gen-thingy=./thingy -I. --thingy_out=. rpc/*.proto

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].