1
0
Fork 0
mirror of https://github.com/Luzifer/korvike.git synced 2024-11-08 15:30:05 +00:00
korvike/func_file.go

21 lines
358 B
Go

package main
import (
"io/ioutil"
"os"
)
func init() {
registerFunction("file", func(name string, v ...string) string {
defaultValue := ""
if len(v) > 0 {
defaultValue = v[0]
}
if _, err := os.Stat(name); err == nil {
if rawValue, err := ioutil.ReadFile(name); err == nil {
return string(rawValue)
}
}
return defaultValue
})
}