1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-13 05:31:08 +08:00

feat(p2p): add ip

This commit is contained in:
源文雨
2024-07-18 02:01:44 +09:00
parent cb2fe9bd21
commit 28c388aca9
11 changed files with 200 additions and 24 deletions

View File

@@ -1,6 +1,10 @@
package helper
import "os"
import (
"os"
"runtime"
"strings"
)
// IsExist 文件/路径存在
func IsExist(path string) bool {
@@ -13,3 +17,21 @@ func IsNotExist(path string) bool {
_, err := os.Stat(path)
return err != nil && os.IsNotExist(err)
}
// FolderName 本文件所在最下级文件夹名
func FolderName() string {
_, file, _, ok := runtime.Caller(1)
if !ok {
return "<unk>"
}
i := strings.LastIndex(file, "/")
if i <= 0 {
return file
}
file = file[:i]
i = strings.LastIndex(file, "/")
if i <= 0 || i+1 >= len(file) {
return file
}
return file[i+1:]
}