bump funcmap@1.1.0

This commit is contained in:
Manfred Touron 2016-12-01 10:08:51 +01:00
parent b6d7814f97
commit bec037ce64
No known key found for this signature in database
GPG Key ID: 9CCF47DF1FD978A1
4 changed files with 25 additions and 6 deletions

View File

@ -1,5 +1,5 @@
FROM golang:1.7.3 FROM znly/protoc
RUN apk --update add make git go rsync
COPY . /go/src/github.com/moul/protoc-gen-gotemplate COPY . /go/src/github.com/moul/protoc-gen-gotemplate
WORKDIR /go/src/github.com/moul/protoc-gen-gotemplate WORKDIR /go/src/github.com/moul/protoc-gen-gotemplate
RUN go install . RUN go install .
ENTRYPOINT ["protoc-gen-gotemplate"]

6
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: 6f0ff21a03d407a4a24bf299f8b80acc931e116457f5378867626c2de5c4265e hash: 8e73e008df139d080692c91cd6c55549bbb6490f00ea67ee7ae1fbf6facedc86
updated: 2016-11-06T18:32:18.567649309+01:00 updated: 2016-12-01T10:08:09.672752932+01:00
imports: imports:
- name: github.com/golang/protobuf - name: github.com/golang/protobuf
version: 98fa357170587e470c5f27d3c3ea0947b71eb455 version: 98fa357170587e470c5f27d3c3ea0947b71eb455
@ -11,5 +11,5 @@ imports:
- name: github.com/kr/fs - name: github.com/kr/fs
version: 2788f0dbd16903de03cb8186e5c7d97b69ad387b version: 2788f0dbd16903de03cb8186e5c7d97b69ad387b
- name: github.com/moul/funcmap - name: github.com/moul/funcmap
version: 916897fb9db8a358561b3c2cdb7bd4d7cf2eb1c7 version: f798117cf01752496ce9b8739b2b1ed21e3a6c1c
testImports: [] testImports: []

View File

@ -8,4 +8,4 @@ import:
- protoc-gen-go/plugin - protoc-gen-go/plugin
- package: github.com/kr/fs - package: github.com/kr/fs
- package: github.com/moul/funcmap - package: github.com/moul/funcmap
version: ~1.0.0 version: ~1.1.0

View File

@ -2,6 +2,8 @@ package funcmap
import ( import (
"encoding/json" "encoding/json"
"fmt"
"strconv"
"strings" "strings"
"text/template" "text/template"
) )
@ -21,6 +23,23 @@ var FuncMap = template.FuncMap{
"split": strings.Split, "split": strings.Split,
"join": strings.Join, "join": strings.Join,
"title": strings.Title, "title": strings.Title,
"unexport": func(v interface{}) string {
return fmt.Sprintf("%s%s", strings.ToLower(v.(string)[0:1]), v.(string)[1:])
},
"lower": strings.ToLower, "lower": strings.ToLower,
"upper": strings.ToUpper, "upper": strings.ToUpper,
"rev": func(v interface{}) string {
runes := []rune(v.(string))
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
return string(runes)
},
"int": func(v interface{}) string {
a, err := strconv.Atoi(v.(string))
if err != nil {
return fmt.Sprintf("%v", v)
}
return fmt.Sprintf("%d", a)
},
} }