我安装回声通过go get -u github.com/labstack/echo/v4它的包装在喜欢go.modmodule appgo 1.15require ( github.com/labstack/echo v3.3.10+incompatible github.com/labstack/echo/v4 v4.2.0) 在 中,使用中间件作为server.gopackage appimport ( "github.com/labstack/echo/v4" "github.com/labstack/echo/middleware")func main() { e := echo.New() e.Use(middleware.Logger())}它提醒 .其他中间件也无法使用。too few arguments in call to middleware.Logger
1 回答
尚方宝剑之说
TA贡献1788条经验 获得超4个赞
试试这个
package main
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.Logger())
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello World")
})
e.Logger.Fatal(e.Start(":9000"))
}
而在go.mod中只有它
module app
go 1.15
require github.com/labstack/echo/v4 v4.2.0
- 1 回答
- 0 关注
- 83 浏览
添加回答
举报
0/150
提交
取消