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

相关推荐
曦樂~2 小时前
【Web Development】02 CSS
前端·css
风骏时光牛马2 小时前
后端服务接口开发与数据逻辑处理
前端
东鹏特饮2 小时前
经典打砖块(Breakout)游戏
前端·css·css3
IT_陈寒2 小时前
Vite的HMR把我整不会了:一个生产环境的热更新坑
前端·人工智能·后端
Mh3 小时前
如何使用双缓冲优化视频切换
前端
risenav3 小时前
低头蓄力,抬头起跳:《萤虫跳跳》的 Rokid AIUI 开发实战
前端
ZhengEnCi3 小时前
如何看待 Fable 5.2 用纯代码生成 1.4MB 视觉作品:光追、水面、倒影、火光的程序化生成原理
前端
再吃一根胡萝卜4 小时前
DSH 插件的 Host 与 Client:为什么「只加载了 Host」,以及要不要自己写 Client 加载器
前端
parade岁月4 小时前
AI 写的前端代码为什么总像 5 年前的?Chrome 官方出手了
前端
tryCbest5 小时前
Vue系列——第 15 篇:内置组件全家桶——Transition、Teleport、Suspense、KeepAlive
前端·vue.js