add helper getEnumValue

This commit is contained in:
jhayotte
2017-05-12 20:46:18 +02:00
parent c750f5de81
commit e1486970f7
7 changed files with 55 additions and 2 deletions

13
examples/enum/Makefile Normal file
View 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

View File

@@ -0,0 +1,9 @@
-red
-blue
-black
-yellow
-green
-dark
-white
-gray
-orange

View File

@@ -0,0 +1,14 @@
syntax = "proto3";
package Sample;
enum Colors {
red = 0;
blue = 1;
black = 2;
yellow = 3;
green = 4;
dark = 5;
white = 6;
gray = 7;
orange = 8;
}

View File

@@ -0,0 +1,2 @@
{{range $m := "colors" | getEnumValue .Enum }}-{{$m.Name}}
{{end}}