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

相关推荐
宿6742 小时前
vue3-包管理器
前端·vue.js
@PHARAOH2 小时前
WHAT - Remix 入门和基本实践:理解两套产物
前端·remix
mayaairi3 小时前
Vue2 生命周期完全指南:从创建到销毁的8个钩子函数
前端·javascript·vue.js
xy34533 小时前
axure9.0 如何打造一个计时器(简单版)
前端·ui·html·axure·原型·产品设计
IMPYLH4 小时前
HTML 的 <pre> 元素
前端·javascript·html
tsumikistep5 小时前
【前端】Vue + Axios 跨域问题实战:7070 代理转发 8080 + 401 报错分析(黑马外卖)
前端·javascript·vue.js
lichenyang4535 小时前
鸿蒙首页从等高商品 Grid 到双列瀑布流:同一张图也能做出小红书式浏览节奏
前端
里欧跑得慢5 小时前
Flutter主题与样式详解
前端·css·flutter·web
计算机魔术师5 小时前
TPU推理性价比翻50%,NVIDIA的护城河要见底了?
前端
IT_陈寒5 小时前
Python的多线程就是个假把式,我算是体验到了
前端·人工智能·后端