Skip to content

proto-gen-tpl is a protoc plugin for generating files using custom templates

License

Notifications You must be signed in to change notification settings

apoprotsky/protoc-gen-tpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protoc-gen-tpl

Go Report Card

Overview

protoc-gen-tpl is a plugin for protobuf compiler (protoc) which allows to generate files using custom templates and rules.

See in checklist implemented and planned features.

Prerequisites

You need protobuf compiler. See instructions on Protocol Buffers site.

Install on Linux using apt

apt install protobuf-compiler

Install on macOS using Homebrew

brew install protobuf

Installation

Install protoc-gen-tpl plugin using go

go get github.com/apoprotsky/protoc-gen-tpl

How to use

Example how to generate go code from proto files

mkdir examples/out
protoc \
  --tpl_out=examples/out \
  --tpl_opt=prefix=github.com/apoprotsky/protoc-gen-tpl/examples/ \
  --tpl_opt=lang=go \
  --tpl_opt=lang=ts \
  --tpl_opt=lang=php \
  examples/proto/*.proto

Option prefix has same behaviour as module=$PREFIX for go plugin.

Option lang designates which languages to use for output files. This option can be specified multiple times.

Checklist

Go

  • Generate go files from proto files
  • Generate structs types from messages
  • Generate struct fields tags
    • Generate json tags
    • Generate custom tags
  • Generate types from enumerations
  • Generate constants from enumerations
  • Supported struct fields types:
    • Scalar types (string, numbers)
    • Arrays
    • Message type
    • Enumeration type

Typescript

  • Generate ts files from proto files
  • Generate interfaces from messages
  • Generate enumerations
  • Supported interface fields types:
    • Scalar types (string, boolean, number, bigint)
    • Arrays
    • Message type
    • Enumeration type

PHP

  • Generate php files from proto files
  • Generate classes from messages
  • Generate constants from enumerations

About

proto-gen-tpl is a protoc plugin for generating files using custom templates

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published