-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using sprig #22
Comments
With the following very naive implementation, there's a ~1MB increase in binary size (from ~16M up to ~17M). We'll need to define diff --git a/cmd/bashbrew/cmd-cat.go b/cmd/bashbrew/cmd-cat.go
index 8edb581..46777a3 100644
--- a/cmd/bashbrew/cmd-cat.go
+++ b/cmd/bashbrew/cmd-cat.go
@@ -9,7 +9,9 @@ import (
"github.com/urfave/cli"
"github.com/docker-library/bashbrew/manifest"
- "github.com/docker-library/bashbrew/pkg/templatelib"
+ //"github.com/docker-library/bashbrew/pkg/templatelib"
+
+ "github.com/Masterminds/sprig/v3"
)
var DefaultCatFormat = `
@@ -48,7 +50,7 @@ func cmdCat(c *cli.Context) error {
}
var i int
- tmpl, err := template.New(templateName).Funcs(templatelib.FuncMap).Funcs(template.FuncMap{
+ tmpl, err := template.New(templateName).Funcs(sprig.TxtFuncMap()).Funcs(template.FuncMap{
"i": func() int {
return i
},
diff --git a/go.mod b/go.mod
index a03278e..f3d2c3b 100644
--- a/go.mod
+++ b/go.mod
@@ -3,6 +3,7 @@ module github.com/docker-library/bashbrew
go 1.13
require (
+ github.com/Masterminds/sprig/v3 v3.2.0
github.com/containerd/containerd v1.4.0
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/go-git/go-git/v5 v5.1.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We should spend more time looking at https://masterminds.github.io/sprig/ and determine whether/how much of https://github.com/docker-library/bashbrew/blob/8e42901deafd7baaf313ad4b655f85507b001746/pkg/templatelib/lib.go we could get rid of by using that instead (since it implements many of the same functions like
first
,last
,ternary
, etc - some just with a different name liketoJson
vs ourjson
).The text was updated successfully, but these errors were encountered: