1
0
Fork 0
mirror of https://github.com/Luzifer/korvike.git synced 2024-11-08 15:30:05 +00:00
korvike/functions/func_file.go
Knut Ahlers fd2a37ca97
Remove default values for file and vault
and add `must*` variants for them

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-02-29 17:55:51 +01:00

27 lines
472 B
Go

package functions
import (
"fmt"
"os"
)
func init() {
registerFunction("file", func(name string) string {
fc, err := tplReadFile(name)
if err != nil {
return ""
}
return fc
})
registerFunction("mustFile", tplReadFile)
}
func tplReadFile(name string) (string, error) {
rawValue, err := os.ReadFile(name) //#nosec:G304 // Intended to load custom file
if err != nil {
return "", fmt.Errorf("reading file: %w", err)
}
return string(rawValue), nil
}