diff --git a/utils/file.go b/utils/file.go new file mode 100644 index 0000000..d4f6e18 --- /dev/null +++ b/utils/file.go @@ -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)) +}