mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 15:10:01 +08:00
chore: initialize some slice type variables (#4249)
This commit is contained in:
@@ -143,7 +143,7 @@ func fillPath(u *nurl.URL, val map[string]any) error {
|
||||
delete(val, key)
|
||||
}
|
||||
|
||||
var unused []string
|
||||
unused := make([]string, 0, len(val))
|
||||
for key := range val {
|
||||
unused = append(unused, key)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (s *Server) PrintRoutes() {
|
||||
|
||||
// Routes returns the HTTP routers that registered in the server.
|
||||
func (s *Server) Routes() []Route {
|
||||
var routes []Route
|
||||
routes := make([]Route, 0, len(s.ngin.routes))
|
||||
|
||||
for _, r := range s.ngin.routes {
|
||||
routes = append(routes, r.routes...)
|
||||
@@ -249,7 +249,7 @@ func WithNotAllowedHandler(handler http.Handler) RunOption {
|
||||
// WithPrefix adds group as a prefix to the route paths.
|
||||
func WithPrefix(group string) RouteOption {
|
||||
return func(r *featuredRoutes) {
|
||||
var routes []Route
|
||||
routes := make([]Route, 0, len(r.routes))
|
||||
for _, rt := range r.routes {
|
||||
p := path.Join(group, rt.Path)
|
||||
routes = append(routes, Route{
|
||||
|
||||
Reference in New Issue
Block a user