add some routes
This commit is contained in:
22
routes/helper.go
Normal file
22
routes/helper.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user