25 lines
390 B
Go
25 lines
390 B
Go
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))
|
|
}
|