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 }