gohttp/util.go

27 lines
389 B
Go

package main
import (
"os"
"path/filepath"
)
func GetExecDir() string {
execPath, err := os.Executable()
if err != nil {
panic(err)
}
return filepath.Dir(execPath)
}
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)
}
}