bshchk/template.go

31 lines
462 B
Go
Raw Normal View History

2024-06-02 11:32:17 +02:00
package main
import (
"bytes"
_ "embed"
"strings"
"text/template"
)
//go:embed rdc.sh
var bin string
type Template struct {
DepsVar string
Deps string
UnsetDeps bool
}
func gencode(deps []string) string {
rdc := Template{args.DepsVarName, "'" + strings.Join(deps, "' '") + "'", !args.ExposeDeps}
tmpl, err := template.New("").Parse(bin)
if err != nil {
panic(err)
}
var buf bytes.Buffer
tmpl.Execute(&buf, rdc)
return buf.String()
}