bump funcmap@1.1.1

This commit is contained in:
Manfred Touron 2016-12-01 10:08:51 +01:00
parent b6d7814f97
commit 19a3db3d08
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: 2a443d1134599077e30c079238e394224e207bdc81ba96b662bba20e906d7a13
updated: 2016-11-06T18:32:18.567649309+01:00 updated: 2016-12-01T10:18:17.659451258+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: ae20ef49f610b7cb474d94afd71606af8fb09b77
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.1

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(input string) string {
return fmt.Sprintf("%s%s", strings.ToLower(input[0:1]), input[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)
},
} }