go-echo

作为 Echo 框架专家,帮助开发者使用这个高性能、极简的 Go Web 框架的优化路由器、中间件链、数据绑定、验证、模板渲染和 WebSocket 支持来构建 REST API 与 Web 应用程序,提供简洁的 API 接口与全面的内置中间件建议。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "go-echo":https://skillpi.com/zh/skills/deepskill-b95c6d1a73355abcbcd2fbf351c87e8994d6ca4e4784c2dce2d5d9d8c6ce1054。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

作为 Echo 框架专家,帮助开发者使用这个高性能、极简的 Go Web 框架的优化路由器、中间件链、数据绑定、验证、模板渲染和 WebSocket 支持来构建 REST API 与 Web 应用程序,提供简洁的 API 接口与全面的内置中间件建议。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: go-echo
description: >-
  You are an expert in Echo, the high-performance, minimalist Go web
  framework. You help developers build REST APIs and web applications using
  Echo's optimized router, middleware chain, data binding, validation,
  template rendering, and WebSocket support — providing a clean API surface
  with excellent performance and comprehensive built-in middleware.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Backend Development
  tags:
    - go
    - web-framework
    - api
    - middleware
    - rest
    - high-performance

Echo — High-Performance Go Web Framework

You are an expert in Echo, the high-performance, minimalist Go web framework. You help developers build REST APIs and web applications using Echo's optimized router, middleware chain, data binding, validation, template rendering, and WebSocket support — providing a clean API surface with excellent performance and comprehensive built-in middleware.

Core Capabilities

Application Setup

package main

import (
    "net/http"
    "github.com/labstack/echo/v4"
    "github.com/labstack/echo/v4/middleware"
)

func main() {
    e := echo.New()

    // Middleware
    e.Use(middleware.Logger())
    e.Use(middleware.Recover())
    e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
        AllowOrigins: []string{"https://app.example.com"},
        AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete},
    }))
    e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(20)))

    // Routes
    e.GET("/users", listUsers)
    e.POST("/users", createUser)
    e.GET("/users/:id", getUser)

    // Groups with middleware
    admin := e.Group("/admin", adminAuth)
    admin.GET("/stats", getStats)

    e.Logger.Fatal(e.Start(":3000"))
}

Handlers and Binding

type CreateUserRequest struct {
    Name  string `json:"name" validate:"required,min=2"`
    Email string `json:"email" validate:"required,email"`
    Age   int    `json:"age" validate:"gte=0,lte=130"`
}

func createUser(c echo.Context) error {
    var req CreateUserRequest
    if err := c.Bind(&req); err != nil {
        return echo.NewHTTPError(http.StatusBadRequest, "Invalid request")
    }
    if err := c.Validate(&req); err != nil {
        return err
    }

    user, err := db.CreateUser(req.Name, req.Email, req.Age)
    if err != nil {
        return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create user")
    }

    return c.JSON(http.StatusCreated, user)
}

func getUser(c echo.Context) error {
    id := c.Param("id")                   // Path param
    user, err := db.FindUser(id)
    if err != nil {
        return echo.NewHTTPError(http.StatusNotFound, "User not found")
    }
    return c.JSON(http.StatusOK, user)
}

func listUsers(c echo.Context) error {
    page, _ := strconv.Atoi(c.QueryParam("page"))  // Query param
    if page < 1 { page = 1 }

    users, total := db.ListUsers(page, 20)
    return c.JSON(http.StatusOK, map[string]interface{}{
        "data": users, "total": total, "page": page,
    })
}

JWT Middleware

import "github.com/labstack/echo-jwt/v4"

// Configure JWT
e.Use(echojwt.WithConfig(echojwt.Config{
    SigningKey: []byte(os.Getenv("JWT_SECRET")),
    Skipper: func(c echo.Context) bool {
        return c.Path() == "/health" || c.Path() == "/login"
    },
}))

// Access claims in handler
func getProfile(c echo.Context) error {
    token := c.Get("user").(*jwt.Token)
    claims := token.Claims.(jwt.MapClaims)
    userID := claims["user_id"].(string)
    // ...
}

Installation

go get github.com/labstack/echo/v4
go get github.com/labstack/echo-jwt/v4

Best Practices

  1. Context methods — Use c.Bind() for request parsing, c.JSON() for responses, c.Param() / c.QueryParam() for params
  2. Groups for versioning — e.Group("/api/v1") with per-group middleware (auth, rate limiting)
  3. HTTPError for responses — Return echo.NewHTTPError(status, message) for consistent error responses
  4. Validator — Register a custom validator with e.Validator; Echo calls it automatically after Bind()
  5. Middleware chaining — e.Use() for global, group-level, or per-route; Echo processes in order
  6. Graceful shutdown — Use e.Shutdown(ctx) with signal handling; drains active connections
  7. Custom context — Extend echo.Context for request-scoped data (user, logger, trace ID)
  8. Static files — e.Static("/assets", "public") for serving static files alongside API routes

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 Echo 框架的完整开发指导,涵盖应用搭建、路由、中间件、数据绑定、JWT 认证等核心能力
  • 面向 Go 开发者构建高性能 Web API 和应用的明确需求,实用价值高
触发精准90/100

亮点

  • 触发描述精准,明确指出是 Echo 框架专家,涵盖 REST API、Web 应用、中间件等关键词,边界清晰
结构规范95/100

待提升项

  • description 内容重复 原报告严重程度:轻微

    frontmatter 和 skill_body 中均包含相同 description 内容,存在轻微冗余

    改进建议:建议移除 skill_body 中的重复 description,保持 frontmatter 中的描述即可

亮点

  • 文档结构清晰,分 Core Capabilities、Installation、Best Practices 等章节
  • 提供完整可运行的代码示例和最佳实践指导
  • frontmatter 元数据完整,包含作者、版本、分类和标签
执行可靠95/100

亮点

  • Go 代码示例语法正确,依赖包路径准确(github.com/labstack/echo/v4)
  • 错误处理机制完善,使用 Bind/Validate/HTTPError 进行合理的请求验证和错误响应
  • 中间件配置完整,涵盖日志、恢复、CORS、速率限制等常见需求
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • app.example.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。