gohttp/utils/util.go

27 lines
390 B
Go
Raw Permalink Normal View History

2023-12-13 17:59:14 +08:00
package utils
2023-12-08 22:02:36 +08:00
import (
"os"
"path/filepath"
)
func GetExecDir() string {
execPath, err := os.Executable()
if err != nil {
panic(err)
}
return filepath.Dir(execPath)
}
2023-12-13 09:22:05 +08:00
func NormalizePath(path string) string {
// return filepath.ToSlash(filepath.Clean(path))
p := filepath.ToSlash(path)
if filepath.IsAbs(p) {
return p
} else {
return filepath.Join(GetExecDir(), p)
}
}