extract getEnvFallback function
1 file changed, 3 insertions(+), 9 deletions(-)
changed files
M templates/files.go → templates/files.go
@@ -3,6 +3,8 @@ import ( "io/fs" "os" + + "go.alanpearce.eu/homestead/internal/env" ) var (@@ -10,16 +12,8 @@ CSS string Files fs.FS ) -func getEnvFallback(key, fallback string) string { - if value, found := os.LookupEnv(key); found { - return value - } - - return fallback -} - func init() { - Files = os.DirFS(getEnvFallback("KO_DATA_PATH", "kodata")) + Files = os.DirFS(env.GetEnvFallback("KO_DATA_PATH", "kodata")) bytes, err := fs.ReadFile(Files, "style.css") if err != nil { panic(err)