feat: add CurrentPath

This commit is contained in:
dudaodong committed 2023-04-05 15:55:55 +08:00
1 parent 3685aee02b
commit 6e7300bbbf
4 files changed
+72

No files matched your search

+13
View File
@@ -15,6 +15,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"
)
@@ -345,3 +346,15 @@ func MiMeType(file any) string {
}
return mediatype
}
// CurrentPath return current absolute path.
// Play: todo
func CurrentPath() string {
var absPath string
_, filename, _, ok := runtime.Caller(1)
if ok {
absPath = path.Dir(filename)
}
return absPath
}