gohttp/util.go

27 lines
389 B
Go
Raw Normal View History

2023-12-08 22:02:36 +08:00
package main
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)
}
}