推荐选型
https://chat.deepseek.com/a/chat/s/e6061607-8f33-4768-a5f0-8970cb1ffefd
echo
github:https://github.com/labstack/echo
wiki:https://echo.labstack.com/docs/quick-start
block:https://blog.csdn.net/qq_38105536/article/details/142659298
示例:
import ("errors""fmt""log/slog""net/http""github.com/labstack/echo/v4/middleware""github.com/labstack/echo/v4"
)func main() {fmt.Println("main ...")e := echo.New()// 添加中间件,这个中间件更像是插件e.Use(middleware.Logger())e.Use(middleware.Recover())// 添加路由e.GET("/hello", hello)e.POST("/hello", hello)// 启动err := e.Start(":8080")// 启动结果if err != nil && !errors.Is(err, http.ErrServerClosed) {slog.Error("start server failed", "error", err)}fmt.Println("success ...")
}// Handler
func hello(c echo.Context) error {return c.String(http.StatusOK, "Hello, World!")
}
gin
参考:https://www.topgoer.com/gin%E6%A1%86%E6%9E%B6/%E7%AE%80%E4%BB%8B.html