From 2e96ae1c9bde571978c30430dcd6e3f5f9807f43 Mon Sep 17 00:00:00 2001 From: George Kelly Date: Mon, 27 Nov 2017 19:48:31 +0000 Subject: Can now take multiple exclude flags --- gomplate.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'gomplate.go') diff --git a/gomplate.go b/gomplate.go index 45cb2548..d1c6bb68 100644 --- a/gomplate.go +++ b/gomplate.go @@ -46,7 +46,7 @@ func runTemplate(o *GomplateOpts) error { g := NewGomplate(d, o.lDelim, o.rDelim) - excludeList, err := filepath.Glob(o.excludeGlob) + excludeList, err := executeCombinedGlob(o.excludeGlob) if err != nil { return err } @@ -69,3 +69,19 @@ func renderTemplate(g *Gomplate, inString string, outPath string) error { err = g.RunTemplate(inString, outFile) return err } + +// takes an array of glob strings and executes it as a whole, +// returning a merged list of globbed files +func executeCombinedGlob(globArray []string) ([]string, error) { + var combinedExcludes []string + for _, glob := range globArray { + excludeList, err := filepath.Glob(glob) + if err != nil { + return nil, err + } + + combinedExcludes = append(combinedExcludes, excludeList...) + } + + return combinedExcludes, nil +} -- cgit v1.2.3