整理打印

This commit is contained in:
2025-10-03 00:54:22 +08:00
parent bff7f73d8b
commit 73480005eb
6 changed files with 63 additions and 3 deletions
+19
View File
@@ -51,3 +51,22 @@ func FprintfArgsMap(layer int, out io.Writer, argsMap map[string]any) error {
}
return nil
}
// FindPathByWd 返回目录基于执行目录
func FindPathByWd(path string) (string, error) {
return FindPathByBasePath(os.Getwd, path)
}
// FindPathByExecutable 返回目录基于exe路径
func FindPathByExecutable(path string) (string, error) {
return FindPathByBasePath(os.Executable, path)
}
func FindPathByBasePath(basefun func() (basePath string, err error), path string) (string, error) {
basePath, err := basefun()
if err != nil {
return "", err
}
path = filepath.Join(filepath.Dir(basePath), path)
return path, nil
}