go WEB框架

推荐选型

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

示例:

Go 复制代码
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框架/简介.html

相关推荐
Cache技术分享2 分钟前
202. Java 异常 - throw 语句的使用
前端·后端
_AaronWong6 分钟前
Electron全局搜索框实战:快捷键调起+实时高亮+多窗口支持
前端·搜索引擎·electron
笔尖的记忆21 分钟前
渲染引擎详解
前端
大明二代27 分钟前
为 Angular Material 应用添加完美深色模式支持
前端
Mintopia34 分钟前
🚪 当 Next.js 中间件穿上保安制服:请求拦截与权限控制的底层奇幻之旅
前端·后端·next.js
Mintopia34 分钟前
🚗💨 “八缸” 的咆哮:V8 引擎漫游记
前端·javascript·v8
源去_云走35 分钟前
npm 包构建与发布
前端·npm·node.js
Sport39 分钟前
面试官:聊聊 Webpack5 的优化方向
前端·面试
码农欧文39 分钟前
关于npm和pnpm
前端·npm·node.js
Restart-AHTCM41 分钟前
前端核心框架vue之(路由核心案例篇3/5)
前端·javascript·vue.js