27 lines
390 B
Go
27 lines
390 B
Go
|
package utils
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
}
|