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

相关推荐
摇滚侠21 分钟前
css 设置边框
前端·css
星爷AG I43 分钟前
9-24 视觉叙事(AGI基础理论)
前端·人工智能
2501_940007891 小时前
Flutter for OpenHarmony三国杀攻略App实战 - 鸿蒙适配与打包发布
前端·flutter
css趣多多1 小时前
跨域问题及Vue项目中本地/线上解决方法核心总结
前端
光影少年1 小时前
前端 AIGC
前端·aigc
启山智软1 小时前
供应链商城核心功能模块清单
java·前端·开源
徐同保1 小时前
Claude Code提示词案例(开发复杂动态路由详情页面)
前端
Σdoughty1 小时前
python第三次作业
开发语言·前端·python
参.商.1 小时前
【Day25】26.删除有序数组中的重复项 80.删除有序数组中的重复项II
leetcode·golang
白中白121381 小时前
Vue系列-2
前端·javascript·vue.js