Skip to content
forked from jhump/goprotoc

Pure-Go protoc replacement to use with go generate

License

Notifications You must be signed in to change notification settings

duckbrain/goprotoc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-protoc

Pure Go version of protoc

This repo contains a pure-Go re-implementation of protoc. This project is forked from jhump/goprotoc and modified to hanlde opts flags and to override the go and go_grpc plugins with built-ins that use go run. This is useful for Go projects that want to avoid a dependency.

The implementaiton delegates to a protoc executable on the path, driving it as if it were a plugin, for generating C++, C#, Objective-C, Java, JavaScript, Python, PHP, and Ruby code (since they are implemented in protoc itself). But it provides descriptors to protoc, parsed by goprotoc, instead of having protoc re-parse all of the source code.

Installation

go get github.com/duckbrain/goprotoc@latest
go get google.golang.org/protobuf/cmd/protoc-gen-go@latest
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

Then in your module, you can replace protoc with go run github.com/duckbrain/goprotoc. So long as the invocation uses only the go and go_grpc plugins, you won't need to install any local generation dependencies besides the go toolchain.

//go:generate go run github.com/duckbrain/goprotoc --go_out=./output --go_opt=paths=source_relative --go_grpc_out=./output --go_grpc_opt=paths=source_relative schema.proto

Goals

This project is intended as a replacement for protoc in projects that want to avoid requireing that as a dev dependency. It's only intended to work within a Go module where the plugin dependencies are already included.

Future scope could include a way to specify additional plugins that are written in pure Go. With the Go 1.24 propoal to manage tool dependencies, this will likely be that all plugins will be invoked with go tool <plugin_name> instead of the current go run <import_path>.

About

Pure-Go protoc replacement to use with go generate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.1%
  • Makefile 1.9%