mirror of
https://github.com/Luzifer/korvike.git
synced 2024-12-20 19:21:17 +00:00
21 lines
363 B
Go
21 lines
363 B
Go
package functions
|
|
|
|
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
|
|
})
|
|
}
|