Add arithmetics helpers - fix #94
This commit is contained in:
13
examples/arithmetics/Makefile
Normal file
13
examples/arithmetics/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
.PHONY: build
|
||||
build:
|
||||
mkdir -p output
|
||||
protoc -I. --gotemplate_out=template_dir=templates,debug=true,all=true:output proto/*.proto
|
||||
|
||||
|
||||
.PHONY: re
|
||||
re: clean build
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf output
|
5
examples/arithmetics/output/arithmetics
Normal file
5
examples/arithmetics/output/arithmetics
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
add(1,2) = 3
|
||||
subtract(1,2) = -1
|
||||
multiply(1,2) = 2
|
||||
divide(2,1) = 2
|
2
examples/arithmetics/proto/arithmetics.proto
Normal file
2
examples/arithmetics/proto/arithmetics.proto
Normal file
@@ -0,0 +1,2 @@
|
||||
syntax = "proto3";
|
||||
package Arithmetics;
|
6
examples/arithmetics/templates/arithmetics.tmpl
Normal file
6
examples/arithmetics/templates/arithmetics.tmpl
Normal file
@@ -0,0 +1,6 @@
|
||||
{{with $a := 1}}{{with $b := 2}}
|
||||
add(1,2) = {{add $a $b}}
|
||||
subtract(1,2) = {{subtract $a $b}}
|
||||
multiply(1,2) = {{multiply $a $b}}
|
||||
divide(2,1) = {{divide $b $a}}
|
||||
{{end}}{{end}}
|
Reference in New Issue
Block a user