Add file util for later

This commit is contained in:
2025-04-13 21:31:19 +02:00
parent c5a68af5e6
commit 58586395fb

24
utils/file.go Normal file
View File

@@ -0,0 +1,24 @@
package utils
import (
"os"
"path/filepath"
"strings"
)
func CleanPath(path string) string {
path = filepath.Clean(path)
path = strings.ReplaceAll(path, "\\", "/")
return path
}
func ToAbs(path string) string {
if filepath.IsAbs(path) {
return CleanPath(path)
}
cwd, err := os.Getwd()
if err != nil {
return CleanPath(path)
}
return CleanPath(filepath.Join(cwd, path))
}