Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

echoecho 搜索

Agent Skill

echo 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

194

周安装

8

GitHub Stars

8

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:echo(echo 搜索)
来源仓库:https://github.com/ar4mirez/samuel
仓库路径:skills/echo
安装命令:
npx skills add https://github.com/ar4mirez/samuel --skill echo
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ar4mirez/samuel --skill echo

简介

Echo v4+ Go 高性能 Web 框架开发指南。

  • 内置 JWT/CORS/Gzip 等成熟中间件生态。
  • 优化 HTTP 路由提升 REST API 吞吐量。
  • 支持 Let's Encrypt 自动 TLS 证书签发。
  • 适合需要极致性能的微服务后端开发场景。echo 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Echo Framework Guide

Applies to: Echo v4+, REST APIs, Microservices, High-Performance Web Applications Language Guide: @.claude/skills/go-guide/SKILL.md

Overview

Echo is a high-performance, extensible, minimalist Go web framework. It features an optimized HTTP router, middleware support, data binding, and rendering.

Use Echo when:

  • You need high performance with minimal overhead
  • You want a clean, intuitive API
  • Built-in middleware matters (JWT, CORS, Gzip, etc.)
  • You prefer automatic TLS via Let's Encrypt

Consider alternatives when:

  • You want the most popular framework (use Gin)
  • You need WebSocket support built-in (use Fiber)
  • Maximum community resources are needed (use Gin)

Project Structure

myproject/
├── cmd/
│   └── api/
│       └── main.go           # Entry point
├── internal/
│   ├── config/
│   │   └── config.go         # Configuration
│   ├── handler/
│   │   ├── handler.go        # Handler container
│   │   ├── user.go           # User handlers
│   │   └── auth.go           # Auth handlers
│   ├── middleware/
│   │   ├── auth.go           # JWT middleware
│   │   └── custom.go         # Custom middleware
│   ├── model/
│   │   ├── user.go           # User model
│   │   └── response.go       # Response models
│   ├── repository/
│   │   ├── repository.go     # Repository interface
│   │   └── user.go           # User repository
│   ├── service/
│   │   ├── service.go        # Service container
│   │   └── user.go           # User service
│   └── validator/
│       └── validator.go      # Custom validators
├── pkg/
│   └── response/
│       └── response.go       # Response helpers
├── migrations/
├── .env.example
├── go.mod
├── go.sum
├── Makefile
└── README.md
  • cmd/ for entry points; one main.go per binary
  • internal/ for private application code; not importable externally
  • handler/ contains Echo handler functions, thin HTTP layer only
  • service/ holds business logic; no Echo or HTTP dependencies
  • repository/ encapsulates data access; accepts context.Context
  • model/ defines domain structs, request/response DTOs
  • middleware/ for custom Echo middleware functions
  • validator/ for custom validation rules via go-playground/validator

Application Setup

e := echo.New()
e.HideBanner = true
e.Validator = validator.NewCustomValidator()

// Global middleware (order matters)
e.Use(echoMw.Recover())   // First: catch panics
e.Use(echoMw.Logger())    // Second: log all requests
e.Use(echoMw.RequestID()) // Third: trace IDs
e.Use(echoMw.CORSWithConfig(echoMw.CORSConfig{
    AllowOrigins: cfg.CORSOrigins,
    AllowMethods: []string{http.MethodGet, http.MethodPost,
        http.MethodPut, http.MethodPatch, http.MethodDelete},
    AllowHeaders: []string{echo.HeaderOrigin,
        echo.HeaderContentType, echo.HeaderAccept,
        echo.HeaderAuthorization},
}))

Setup guidelines:

  • Set e.HideBanner = true in production
  • Register Recover() first to catch panics in all handlers
  • Use RequestID() for distributed tracing
  • Always implement graceful shutdown with e.Shutdown(ctx)
  • See references/patterns.md for full main.go with graceful shutdown

Routing

Route Groups and Versioning

func setupRoutes(e *echo.Echo, h *handler.Handlers, authMw *middleware.AuthMiddleware) {
    // Health check (ungrouped)
    e.GET("/health", func(c echo.Context) error {
        return c.JSON(http.StatusOK, map[string]string{"status": "ok"})
    })

    // API v1
    v1 := e.Group("/api/v1")

    // Public routes
    auth := v1.Group("/auth")
    auth.POST("/login", h.Auth.Login)
    auth.POST("/register", h.Auth.Register)
    auth.POST("/refresh", h.Auth.Refresh)

    // Protected routes
    users := v1.Group("/users")
    users.POST("", h.User.Create)
    users.Use(authMw.Authenticate)
    users.GET("", h.User.GetAll)
    users.GET("/me", h.User.GetCurrent)
    users.GET("/:id", h.User.GetByID)
    users.PUT("/:id", h.User.Update)
    users.DELETE("/:id", h.User.Delete, authMw.RequireAdmin)
}

Routing guidelines:

  • Group routes by resource and version (/api/v1/users)
  • Apply middleware at group level, not per-route when possible
  • Use /:param for path parameters (e.g., /:id)
  • Append per-route middleware as extra handler args (e.g., RequireAdmin)
  • Keep health check outside API groups for monitoring tools

Middleware

Built-in Middleware (use these first)

MiddlewarePurpose
Recover()Catch panics, return 500
Logger()Request logging
RequestID()Unique request IDs
CORS()Cross-origin requests
Gzip()Response compression
RateLimiter()Rate limiting
Secure()Security headers
BodyLimit()Request size limits

Custom Middleware Pattern

// Middleware that injects request-scoped values
func RequestTimerMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
    return func(c echo.Context) error {
        start := time.Now()
        err := next(c)
        duration := time.Since(start)
        c.Response().Header().Set("X-Response-Time",
            duration.String())
        return err
    }
}

// Middleware with configuration
type RateLimitConfig struct {
    Rate  int
    Burst int
}

func RateLimitMiddleware(cfg RateLimitConfig) echo.MiddlewareFunc {
    limiter := rate.NewLimiter(
        rate.Limit(cfg.Rate), cfg.Burst,
    )
    return func(next echo.HandlerFunc) echo.HandlerFunc {
        return func(c echo.Context) error {
            if !limiter.Allow() {
                return c.JSON(http.StatusTooManyRequests,
                    model.ErrorResponse("rate limit exceeded"))
            }
            return next(c)
        }
    }
}

Middleware guidelines:

  • Return echo.HandlerFunc from middleware
  • Call next(c) to continue the chain; skip to short-circuit
  • Configurable middleware returns echo.MiddlewareFunc
  • Order matters: register Recover() first, then logging, then auth

Echo Context

Reading Values

func handler(c echo.Context) error {
    // Path params
    id := c.Param("id")

    // Query params
    page := c.QueryParam("page")
    search := c.QueryParam("q")

    // Form values
    name := c.FormValue("name")

    // Headers
    token := c.Request().Header.Get("Authorization")

    // Request-scoped values (set by middleware)
    userID, ok := c.Get("user_id").(uint)

    // Real IP (respects X-Forwarded-For)
    ip := c.RealIP()

    // Underlying context.Context for DB/service calls
    ctx := c.Request().Context()

    return c.JSON(http.StatusOK, data)
}

Context guidelines:

  • Use c.Request().Context() when passing to services/repositories
  • Use c.Get()/c.Set() for request-scoped values between middleware and handlers
  • Type-assert values from c.Get() with ok check
  • Never store echo.Context beyond the request lifecycle

Request Binding and Validation

Binding

type CreateUserRequest struct {
    Email     string `json:"email" validate:"required,email"`
    Password  string `json:"password" validate:"required,min=8"`
    FirstName string `json:"first_name" validate:"required,min=1,max=100"`
    LastName  string `json:"last_name" validate:"required,min=1,max=100"`
}

func (h *UserHandler) Create(c echo.Context) error {
    var req CreateUserRequest
    if err := c.Bind(&req); err != nil {
        return c.JSON(http.StatusBadRequest,
            model.ErrorResponse(err.Error()))
    }
    if err := c.Validate(&req); err != nil {
        return err // Custom validator returns HTTPError
    }
    // Process valid request...
}

Custom Validator

type CustomValidator struct {
    validator *validator.Validate
}

func NewCustomValidator() *CustomValidator {
    v := validator.New()
    v.RegisterTagNameFunc(func(fld reflect.StructField) string {
        name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
        if name == "-" {
            return ""
        }
        return name
    })
    return &CustomValidator{validator: v}
}

func (cv *CustomValidator) Validate(i interface{}) error {
    if err := cv.validator.Struct(i); err != nil {
        return echo.NewHTTPError(
            http.StatusBadRequest,
            formatValidationErrors(err),
        )
    }
    return nil
}

Binding guidelines:

  • Always Bind then Validate as separate steps
  • Use struct tags: json for binding, validate for rules
  • Register custom validator on e.Validator at startup
  • Return structured validation errors, not raw messages
  • Use pointer fields for optional/partial updates (*string)

Response Patterns

Use a consistent JSON envelope across all endpoints:

// Success: c.JSON(http.StatusOK, SuccessResponse(data))
// Error:   c.JSON(http.StatusNotFound, ErrorResponse("not found"))
// Delete:  c.NoContent(http.StatusNoContent)

type Response struct {
    Success bool        `json:"success"`
    Data    interface{} `json:"data,omitempty"`
    Error   string      `json:"error,omitempty"`
}

func SuccessResponse(data interface{}) *Response {
    return &Response{Success: true, Data: data}
}

func ErrorResponse(msg string) *Response {
    return &Response{Success: false, Error: msg}
}
  • Use response DTOs; never expose domain models directly (omit passwords, internal IDs)
  • For paginated responses, include meta with page/total counts
  • See references/patterns.md for PaginatedResponse struct

Error Handling

Domain Errors

var (
    ErrUserNotFound       = errors.New("user not found")
    ErrUserAlreadyExists  = errors.New("user already exists")
    ErrInvalidCredentials = errors.New("invalid credentials")
)

Handler Error Mapping

func (h *UserHandler) GetByID(c echo.Context) error {
    id, err := strconv.ParseUint(c.Param("id"), 10, 32)
    if err != nil {
        return c.JSON(http.StatusBadRequest,
            model.ErrorResponse("invalid user ID"))
    }

    user, err := h.userService.GetByID(
        c.Request().Context(), uint(id),
    )
    if err != nil {
        if errors.Is(err, service.ErrUserNotFound) {
            return c.JSON(http.StatusNotFound,
                model.ErrorResponse(err.Error()))
        }
        return c.JSON(http.StatusInternalServerError,
            model.ErrorResponse(err.Error()))
    }

    return c.JSON(http.StatusOK,
        model.SuccessResponse(user.ToResponse()))
}

Error handling guidelines:

  • Define domain errors as sentinel values in the service layer
  • Map domain errors to HTTP status codes in handlers only
  • Use errors.Is() / errors.As() for error checking
  • Never expose internal errors to clients in production
  • Log detailed errors server-side; return safe messages to clients

Configuration

  • Load from environment variables (12-factor app) via godotenv
  • Provide sensible defaults for development only
  • Never hardcode secrets; use empty defaults to force explicit config
  • Parse durations and validate at startup, not at use time
  • See references/patterns.md for full config struct example

Commands Reference

# Initialize project
go mod init myproject

# Install dependencies
go mod tidy

# Run development server
go run cmd/api/main.go

# Build binary
go build -o bin/api cmd/api/main.go

# Run tests
go test ./...
go test -v -cover ./...

# Run with race detection
go test -race ./...

# Lint
golangci-lint run

# Database migrations (golang-migrate)
migrate -path migrations -database "$DATABASE_URL" up
migrate -path migrations -database "$DATABASE_URL" down

Dependencies

// Core
github.com/labstack/echo/v4          // Web framework
github.com/go-playground/validator/v10 // Validation
github.com/golang-jwt/jwt/v5          // JWT auth
github.com/joho/godotenv              // Env loading

// Database
gorm.io/gorm                          // ORM
gorm.io/driver/postgres               // PostgreSQL driver

// Crypto
golang.org/x/crypto                    // bcrypt, etc.

// Testing
github.com/stretchr/testify           // Assertions and mocks

Best Practices Checklist

Echo-Specific

  • Use custom validator with go-playground/validator
  • Use echo.Context for request handling only (not in services)
  • Use middleware groups for route organization
  • Return errors from handlers for centralized handling
  • Use echo.Bind for request binding
  • Configure proper timeouts and graceful shutdown
  • Set e.HideBanner = true in production

Performance

  • Configure database connection pooling (SetMaxOpenConns, etc.)
  • Implement pagination for list endpoints
  • Use Gzip() middleware for response compression
  • Implement request logging middleware for observability
  • Use BodyLimit() to prevent oversized requests

Advanced Topics

For detailed patterns and examples, see:

External References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.54%
按下载量换算23

Claude

30.11%
按下载量换算19

Cursor

19.17%
按下载量换算12

Gemini CLI

9.71%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills