easygen
easygen copied to clipboard
Wiki: V1 & V2
(Repost from https://github.com/go-easygen/easygen/wiki/V1-&-V2)
Version 1
Info
https://gopkg.in/easygen.v1
Sample code, V1
func exampleV1(templateFile string, config templateData) error {
t, err := easygen.ParseFiles(false, templateFile)
check(err)
env := make(map[string]string)
for _, e := range os.Environ() {
sep := strings.Index(e, "=")
env[e[0:sep]] = e[sep+1:]
}
config.ENV = env
err = t.Execute(os.Stdout, config)
return err
}
Version 2
https://gopkg.in/easygen.v2
Sample code, V2
See
https://github.com/go-easygen/easygen/blob/8022ae39b5b2aa9001f159eeabaa82c7d010474d/example_test.go#L12-L29
In above code, to define tmpl with basic easygen functions without the addon ones, do
tmpl := easygen.NewTemplate().Funcs(easygen.FuncDefs())