1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-23 12:00:34 +08:00

feat: impl. new protol design & new head

This commit is contained in:
源文雨
2025-03-12 22:20:02 +09:00
parent 60209117b7
commit f4fd9b1423
49 changed files with 1643 additions and 1137 deletions

37
internal/file/file.go Normal file
View File

@@ -0,0 +1,37 @@
package file
import (
"os"
"runtime"
"strings"
)
// IsExist 文件/路径存在
func IsExist(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsExist(err)
}
// IsNotExist 文件/路径不存在
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:]
}