From 6d0ee10322db05b0ec61622e5de1d1a6a1af43f0 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 16 Mar 2017 16:10:39 +0100 Subject: [PATCH] Add *philosophy* and *under the hood* sections --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46e6810..239738a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,26 @@ # `protoc-gen-gotemplate` :open_file_folder: protocol generator + golang text/template (protobuf) -Generic protocol buffer generator backed by Golang's [text/template](https://golang.org/pkg/text/template). +A generic **code**/script/data generator based on [Protobuf](https://developers.google.com/protocol-buffers/). --- This is a generator plugin for the Google Protocol Buffers compiler (`protoc`). -The plugin can generate files based on a template directory using the [Golang's `text/template`](https://golang.org/pkg/text/template/) engine. +The plugin parses **protobuf** files, generates an **ast**, and walks a local **templates directory** to generate files using the [Golang's `text/template` engine](https://golang.org/pkg/text/template/). + +## Philosophy + +* protobuf-first +* no built-in template, only user defined templates +* kiss, *keep it stupid simple* + +## Under the hood + +1. the *user* `protobuf` files are parsed by [`protoc`](https://github.com/google/protobuf/releases) +2. the `ast` is generated by [`protoc-gen-go` helpers](https://github.com/golang/protobuf/tree/master/protoc-gen-go) +3. the `ast` is given to [Golang's `text/template` engine](https://golang.org/pkg/text/template/) for each *user* template files +4. the *funcmap* enriching the template engine is based on [Masterminds/sprig](https://github.com/Masterminds/sprig), and contains type-manipulation, iteration and language-specific helpers ## Usage @@ -52,6 +65,10 @@ Non-exhaustive list of new helpers: See the project helpers for the complete list. +## Hacks + + + ## Install * Install the **Go** compiler and tools from https://golang.org/doc/install