Embedded the Templates in the go binary
Build / Build (push) Successful in 1m26s

This commit is contained in:
2025-05-19 21:46:38 +02:00
parent 1f05960ffc
commit 41437f0f2f
2 changed files with 8 additions and 3 deletions
+3 -2
View File
@@ -3,6 +3,7 @@ package proto
import (
"bytes"
"encoding/json"
"io/fs"
"log"
"strconv"
"text/template"
@@ -73,13 +74,13 @@ type CStyleData struct {
var tmpl *template.Template
func InitTemplates() {
func InitTemplates(fsys fs.FS, pattern string) {
funcs := template.FuncMap{
"snake": toSnakeCase,
"isLast": isLast,
}
Ntmpl, err := template.New("all").Funcs(funcs).ParseGlob("templates/*.tmpl")
Ntmpl, err := template.New("all").Funcs(funcs).ParseFS(fsys, pattern)
if err != nil {
log.Fatalf("failed to parse templates: %v", err)
}