我正在尝试合并多个片段,如下所示,
package routes
import (
"net/http"
)
type Route struct {
Name string
Method string
Pattern string
Secured bool
HandlerFunc http.HandlerFunc
}
type Routes []Route
var ApplicationRoutes Routes
func init() {
ApplicationRoutes = append(
WifiUserRoutes,
WifiUsageRoutes,
WifiLocationRoutes,
DashboardUserRoutes,
DashoardAppRoutes,
RadiusRoutes,
AuthenticationRoutes...
)
}
然而,内置的append()函数可以追加两个切片,因此在编译时会抛出too many arguments to append错误。是否有替代函数来实现这个任务?或者是否有更好的方法来合并这些切片?
slices.Concat
函数 应该会有所帮助。 - undefined