feat: add nfctl(ctl to start nf project)

This commit is contained in:
loveuer
2024-07-12 16:00:15 +08:00
parent 8a423c2887
commit 0f139cda98
14 changed files with 593 additions and 111 deletions

29
nft/nfctl/tp/render.go Normal file
View File

@ -0,0 +1,29 @@
package tp
import (
"bytes"
"text/template"
)
var (
_t *template.Template
)
func init() {
_t = template.New("tp")
}
func RenderVar(t []byte, data map[string]any) ([]byte, error) {
tr, err := _t.Parse(string(t))
if err != nil {
return nil, err
}
var buf bytes.Buffer
if err = tr.Execute(&buf, data); err != nil {
return nil, err
}
return buf.Bytes(), nil
}