proxy-detector/pkg/templates/init.go
2024-12-10 20:19:13 +08:00

26 lines
452 B
Go

package templates
import (
_ "embed"
"os"
"path/filepath"
)
var DefaultTemplate = "./template_meta.yaml"
//go:embed template_meta.yaml
var templateMeta string
func init() {
path := filepath.Join("./templates", DefaultTemplate)
_ = os.MkdirAll("./templates", 0755)
if _, err := os.Stat(path); os.IsNotExist(err) {
f, _err := os.Create(path)
if _err != nil {
panic(_err)
}
defer f.Close()
_, err = f.WriteString(templateMeta)
}
}