gin
Skill15 starsChanged 45 days agoMITView on GitHub
Expert Gin Go web framework assistance covering fast HTTP routing, middleware chains, JSON binding, and group routing. Use when building production-ready REST APIs in Go.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- youlaitech/youlai-skillstheir own version, first seen Jul 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- youlaitech/youlai-skills★ 63same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository350 other files it gives its agents.
- airflowSkill
- catboostSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- matplotlibSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 140
Use Gin's struct tag binding with binding:"required":
- Very specific: line 163
Use gin.SetMode(gin.ReleaseMode) in production environments to disable debug logging and increase throughput.
- Very specific: line 164
Use c.ShouldBindJSON instead of c.BindJSON to retain explicit control over HTTP status error codes.
- Very specific: line 165
Use c.Copy() if passing the Gin context to concurrent background goroutines.
- Very specific: line 170
Use gin.Default() in production if you want customized, structured logging (gin.New() + custom logger).
- Very specific: line 171
Read c.Request.Body multiple times without buffering.
- Very specific: line 172
Write to c.Writer after returning an error.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gin
Gin is a high-performance HTTP web framework written in Go, featuring a fast radix-tree router, composable middleware chains, and structured request validation.
When to Use
- High-Throughput Go Microservices: Building low-latency web services with martini-like API and fast radx tree routing.
- JSON REST APIs: Serializing and deserializing payloads with strong validation and minimal allocation overhead.
- Microservice Middleware Stacks: Implementing custom logging, auth, rate limiting, and recovery middleware.
- File Upload & Static Asset Serving: Fast static asset handling and multipart streaming.
Quick Start
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/api/ping", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "pong"})
})
r.Run(":8080")
}Core Concepts
Radix Tree Routing & Parameter Binding
Fast route matching with typed model binding:
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
type CreateAccountRequest struct {
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required,min=8"`
}
func main() {
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
v1 := r.Group("/api/v1")
{
v1.GET("/health", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "UP"})
})
v1.POST("/accounts", func(c *gin.Context) {
var req CreateAccountRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, gin.H{"email": req.Email, "id": 1001})
})
}
_ = r.Run(":8080")
}Custom Middleware Pipeline
Intercepting requests and calculating execution latency:
package main
import (
"log"
"time"
"github.com/gin-gonic/gin"
)
func LatencyTracker() gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
c.Next() // Process subsequent handlers
latency := time.Since(start)
status := c.Writer.Status()
log.Printf("[GIN] %s %s | %d | %v", c.Request.Method, c.Request.URL.Path, status, latency)
}
}Structured Validation Error Responses
Converting Go validator errors into actionable API responses:
import (
"errors"
"net/http"
"github.com/go-playground/validator/v10"
"github.com/gin-gonic/gin"
)
func handleValidationError(c *gin.Context, err error) {
var ve validator.ValidationErrors
if errors.As(err, &ve) {
out := make(map[string]string)
for _, fe := range ve {
out[fe.Field()] = "Failed validation rule: " + fe.Tag()
}
c.JSON(http.StatusUnprocessableEntity, gin.H{"errors": out})
return
}
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
}Common Patterns
Request Validation with ShouldBindJSON
Problem: Manually validating JSON fields leads to verbose boilerplate and runtime type bugs.
Solution:
Use Gin's struct tag binding with binding:"required":
type CreateOrderRequest struct {
ItemId string `json:"item_id" binding:"required"`
Quantity int `json:"quantity" binding:"required,gt=0"`
Price float64 `json:"price" binding:"required,gt=0"`
}
func CreateOrderHandler(c *gin.Context) {
var req CreateOrderRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, gin.H{"status": "created", "item_id": req.ItemId})
}Best Practices
Do:
- Use
gin.SetMode(gin.ReleaseMode)in production environments to disable debug logging and increase throughput. - Use
c.ShouldBindJSONinstead ofc.BindJSONto retain explicit control over HTTP status error codes. - Use
c.Copy()if passing the Gin context to concurrent background goroutines. - Attach
gin.Recovery()to avoid server crashes from uncaught panics.
Don't:
- Use
gin.Default()in production if you want customized, structured logging (gin.New()+ custom logger). - Read
c.Request.Bodymultiple times without buffering; reading drains the request stream. - Write to
c.Writerafter returning an error.
Troubleshooting
| Error | Cause | Solution |
Headers were already written | Handler returned without exiting after writing response. | Add return statement immediately after calling c.JSON() or c.AbortWithStatus(). |
[GIN-debug] [WARNING] Headers were already written | Middleware executed c.Next() after writing response body. | Only call c.Next() prior to response generation or handle conditionally. |
panic: [recovery] recovered: assignment to entry in nil map | Inserting key into uninitialized gin.H map variable. | Initialize map with gin.H{} or make(map[string]any). |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

