Giter Site home page Giter Site logo

oyato / oh-my-gogo-protoc Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 8 KB

oh-my-gogo-protoc is a wrapper around the protobuf compiler (protoc) that automatically sets it up for use with gogo/protobuf and Go modules.

Home Page: https://oya.to/oh-my-gogo-protoc

License: MIT License

Go 100.00%
protobuf golang go twirp grpc gogo-protobuf protoc

oh-my-gogo-protoc's Introduction

oh-my-gogo-protoc

What it is?

oh-my-gogo-protoc is a wrapper around the protobuf compiler (protoc) that automatically sets it up for use with https://github.com/gogo/protobuf and Go modules.

How does it work?

  • Given your current command protoc ... --gofast_out=Mgoogle...:. my.proto, it sees you're using the gofast generator and:
  • Automatically runs go install github.com/gogo/protobuf/protoc-gen-gofast.
  • Then it runs protoc --proto_path=...github.com/gogo/protobuf/protobuf@1... my.proto i.e. with the correct include paths** and the google/protobuf/*.proto=github.com/gogo/protobuf/types mappings.

Replace gofast_out with gogoslick_out or any other generator you prefer. It will figure it out and install and set up the appropriate binary.

Why should I use it?

It makes working with Go modules and gogo/protobuf easy and pain-free.

Typically, to use gogo/protobuf you run protoc with a bunch of params like -I$GOPATH/src/.... This doesn't work for Go modules because the directory is at $GOPATH/pkg/mod/github.com/gogo/protobuf@version/... so you need a work-around involving go list -f {{.Dir}}... which may or may not work. It also doesn't work if $GOPATH is a list of directories.

How do I install and use it?

  • In your module dir, run go get oya.to/oh-my-gogo-protoc.
  • In your source file add or edit your go generate directive //go:generate go run oya.to/oh-my-gogo-protoc --gofast_out=. my.proto. That's it.
  • Don't forget to install the gogo/proto deps you need e.g. go get github.com/gogo/protobuf/protoc-gen-gofast

Can I use it with Twirp RPC?

Yes, if you pass --twirp_out, it knows to automatically go install github.com/twitchtv/twirp/protoc-gen-twirp as well.

Is it production ready?

Yes! we've literally been using it to generate over 1 go package since an hour ago, so you know it's battle tested.

oh-my-gogo-protoc's People

Contributors

disposaboy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.