[feat] 新增 GetAbsPath 方法

This commit is contained in:
what-00 2023-04-13 11:06:42 +08:00
parent f3d4de13b2
commit 9426da7d6b

View File

@ -2,6 +2,8 @@ package support
import (
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
"unsafe"
@ -161,3 +163,13 @@ func UcFirst(s string) string {
func StudlyCase(s string) string {
return strings.Replace(strings.Title(strings.Replace(s, "-", " ", -1)), " ", "", -1)
}
func GetAbsPath(s string) string {
if strings.HasPrefix(s, "/") {
return s
} else if dir, err := os.Getwd(); err == nil {
return filepath.Join(dir, s)
}
return s
}