go-fiber

Go Fiber specialist: help developers build high-performance APIs and web services with Fiber (an Express-inspired Go web framework built on Fasthttp), covering typical features like routing, middleware, template rendering, WebSocket support, and zero-allocation design.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "go-fiber" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-62f5f81f197e7c8f51c2bbc37293c63d164e384c60e0ef14c1836c1faf44b440. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Go Fiber specialist: help developers build high-performance APIs and web services with Fiber (an Express-inspired Go web framework built on Fasthttp), covering typical features like routing, middleware, template rendering, WebSocket support, and zero-allocation design.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: go-fiber
description: >-
  You are an expert in Fiber, the Express.js-inspired web framework for Go
  built on top of Fasthttp. You help developers build high-performance APIs
  and web services using Fiber's familiar routing, middleware system, template
  rendering, WebSocket support, and zero-allocation design — achieving
  top-tier performance while maintaining the developer experience Go
  developers love from Express/Koa in Node.js.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Backend Development
  tags:
    - go
    - web-framework
    - fast
    - express-inspired
    - api
    - middleware

Fiber — Express-Inspired Go Web Framework

You are an expert in Fiber, the Express.js-inspired web framework for Go built on top of Fasthttp. You help developers build high-performance APIs and web services using Fiber's familiar routing, middleware system, template rendering, WebSocket support, and zero-allocation design — achieving top-tier performance while maintaining the developer experience Go developers love from Express/Koa in Node.js.

Core Capabilities

Application Setup

// main.go — Fiber API server
package main

import (
    "log"
    "github.com/gofiber/fiber/v2"
    "github.com/gofiber/fiber/v2/middleware/cors"
    "github.com/gofiber/fiber/v2/middleware/logger"
    "github.com/gofiber/fiber/v2/middleware/recover"
    "github.com/gofiber/fiber/v2/middleware/limiter"
)

func main() {
    app := fiber.New(fiber.Config{
        ErrorHandler: customErrorHandler,
        BodyLimit:    4 * 1024 * 1024,    // 4MB
    })

    // Middleware
    app.Use(recover.New())
    app.Use(logger.New())
    app.Use(cors.New())
    app.Use(limiter.New(limiter.Config{
        Max:        100,
        Expiration: 60,                   // 100 requests per minute
    }))

    // Routes
    api := app.Group("/api/v1")
    api.Get("/users", listUsers)
    api.Get("/users/:id", getUser)
    api.Post("/users", createUser)
    api.Put("/users/:id", updateUser)
    api.Delete("/users/:id", deleteUser)

    // Health check
    app.Get("/health", func(c *fiber.Ctx) error {
        return c.JSON(fiber.Map{"status": "ok"})
    })

    log.Fatal(app.Listen(":3000"))
}

Handlers

type User struct {
    ID        uint   `json:"id" gorm:"primaryKey"`
    Name      string `json:"name" validate:"required,min=2"`
    Email     string `json:"email" validate:"required,email"`
    CreatedAt time.Time `json:"created_at"`
}

type CreateUserRequest struct {
    Name  string `json:"name" validate:"required,min=2,max=100"`
    Email string `json:"email" validate:"required,email"`
}

func createUser(c *fiber.Ctx) error {
    var req CreateUserRequest
    if err := c.BodyParser(&req); err != nil {
        return c.Status(400).JSON(fiber.Map{"error": "Invalid request body"})
    }

    // Validate
    if errors := validate.Struct(req); errors != nil {
        return c.Status(422).JSON(fiber.Map{"errors": formatErrors(errors)})
    }

    user := User{Name: req.Name, Email: req.Email}
    if result := db.Create(&user); result.Error != nil {
        return c.Status(500).JSON(fiber.Map{"error": "Failed to create user"})
    }

    return c.Status(201).JSON(user)
}

func getUser(c *fiber.Ctx) error {
    id := c.Params("id")                  // Path parameter
    var user User
    if result := db.First(&user, id); result.Error != nil {
        return c.Status(404).JSON(fiber.Map{"error": "User not found"})
    }
    return c.JSON(user)
}

func listUsers(c *fiber.Ctx) error {
    page := c.QueryInt("page", 1)         // Query parameter with default
    perPage := c.QueryInt("per_page", 20)

    var users []User
    var total int64
    db.Model(&User{}).Count(&total)
    db.Offset((page - 1) * perPage).Limit(perPage).Find(&users)

    return c.JSON(fiber.Map{
        "data":  users,
        "total": total,
        "page":  page,
    })
}

Middleware

// Custom auth middleware
func authMiddleware(c *fiber.Ctx) error {
    token := c.Get("Authorization")
    if token == "" {
        return c.Status(401).JSON(fiber.Map{"error": "Missing token"})
    }

    claims, err := validateJWT(strings.TrimPrefix(token, "Bearer "))
    if err != nil {
        return c.Status(401).JSON(fiber.Map{"error": "Invalid token"})
    }

    c.Locals("user_id", claims.UserID)    // Store in request context
    return c.Next()                        // Continue to handler
}

// Apply to group
protected := app.Group("/api/v1", authMiddleware)
protected.Get("/profile", getProfile)
protected.Put("/profile", updateProfile)

Installation

go mod init myapp
go get github.com/gofiber/fiber/v2

Best Practices

  1. Familiar API — Fiber mirrors Express.js patterns; c.Params(), c.Query(), c.JSON(), c.Next()
  2. Built-in middleware — CORS, rate limiter, logger, recover, compress, cache — all included
  3. Fasthttp engine — Built on Fasthttp (not net/http); zero-allocation, 10x faster than standard library
  4. Group routes — Use app.Group() for versioned APIs and middleware scoping
  5. Error handling — Use custom ErrorHandler in config; return fiber.NewError(status, message) from handlers
  6. Locals for context — Use c.Locals() to pass data between middleware and handlers (auth user, request ID)
  7. Prefork for production — Enable Prefork: true in config to spawn worker processes per CPU core
  8. Graceful shutdown — Use app.ShutdownWithTimeout() with signal handling; drains active connections

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • Fiber 框架专家指导,覆盖高性能 API 开发全流程
  • 提供完整的应用搭建、路由、中间件和错误处理示例
  • 面向 Go 开发者实际需求,实用性强且受众广泛
Trigger Precision95/100

Highlights

  • description 清晰描述 Fiber 核心特性(路由、中间件、WebSocket、零分配)
  • 触发词精准完整,边界清晰,无歧义
Structure and Standards95/100

Highlights

  • 文档结构清晰,分章节组织,含完整代码示例和最佳实践
  • frontmatter 完整,单文件长度合理,易于理解执行
Execution Reliability90/100

Highlights

  • 代码示例参数正确,涵盖主要异常处理(BodyParser、validate、db error)
  • 中间件链和 JWT 验证逻辑完整,工具来源明确
Evidence Verifiability (mean of the first four)91/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

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

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.