Files
bdgrp_go/routes/helper.go
2026-09-03 18:48:23 +08:00

23 lines
319 B
Go

package routes
import (
"runtime"
"strings"
)
func PathOf() string {
_, file, _, _ := runtime.Caller(1)
// 取 routes/ 之後的部分
idx := strings.Index(file, "routes/")
if idx == -1 {
return "/"
}
path := file[idx+len("routes"):]
// 去掉 .go
path = strings.TrimSuffix(path, ".go")
return path
}