1
0

🏗️」 wip: need to test rmnl func

This commit is contained in:
2025-03-05 20:21:07 +01:00
parent 055ccdc1df
commit 10cc7cd152

View File

@ -7,8 +7,14 @@ import (
"git.keyzox.me/42_adjoly/inception/internal/log" "git.keyzox.me/42_adjoly/inception/internal/log"
) )
func removeNl(in string) string { func rmNewline(s string) string {
// Check if the string is not empty and the last character is a newline
if len(s) > 0 && s[len(s)-1] == '\n' {
// Return the string without the last character
return s[:len(s)-1]
}
// Return the original string if there is no newline at the end
return s
} }
// Check if the "Value" exist in the env if not check if a "Value_FILE" exist and if still not just return default value // Check if the "Value" exist in the env if not check if a "Value_FILE" exist and if still not just return default value
@ -24,7 +30,7 @@ func FileEnv(Value, Default string) string {
if err != nil { if err != nil {
_log.Log("error", "Error reading file") _log.Log("error", "Error reading file")
} }
return string(content) return rmNewline(string(content))
} }
} }
return Default return Default