go-standard-library

Correct Go standard library misuse in time, JSON, SQL, and HTTP code.

15|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/v0lka/skills --skill go-standard-library
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-standard-library
Source: https://github.com/v0lka/skills/tree/main/development/idiomatic-go/go-standard-library
Command: npx skills add https://github.com/v0lka/skills --skill go-standard-library

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go developers frequently misuse the standard library, leading to subtle bugs, performance issues, and hard-to-track failures.

Core Features & Use Cases

  • Guidance on correct patterns for time, encoding/json, database/sql, and net/http.
  • Practical examples showing common pitfalls and safe replacements suitable for reviews and linting.
  • Real-world scenarios including server-side handling and data serialization where correctness matters.

Quick Start

Run a quick review of a Go project and fix the most critical stdlib usage issues.

Frequently Asked Questions about go-standard-library

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix time.After memory leaks in Go production services?

To fix time.After memory leaks in Go, you must avoid using it in long-running loops where the timer is not garbage collected until it fires. Safe replacements involve using time.NewTimer with explicit Stop and Reset calls to manage resources correctly.

Why does sql.Open fail to connect to my database in Golang?

sql.Open does not actually establish a database connection in Golang; it merely validates the arguments. You must call the Ping method immediately after sql.Open to verify the connection and configure the connection pool for production reliability.

What are the best practices for HTTP client and server timeouts in Go?

Best practices for HTTP client and server timeouts in Go require explicitly setting Timeout, ReadTimeout, and WriteTimeout fields. Relying on default zero values leaves production services vulnerable to slowloris attacks and resource exhaustion from hanging connections.

How do I correctly handle JSON marshaling and embedding in Go?

Correct JSON marshaling and embedding in Go requires understanding struct tag behavior and how embedded fields interact with the encoding/json package. Proper patterns prevent silent data omission and incorrect serialization during data processing.

What is the correct way to use time.Duration in Go?

The correct way to use time.Duration in Go is to treat it as an integer representing nanoseconds, avoiding common multiplier mistakes. Applying the correct units prevents subtle bugs in time handling and scheduling logic within production services.

How do I safely close resources in a Go standard library application?

To safely close resources in a Go application, you must use defer statements immediately after successful resource allocation. This pattern ensures HTTP response bodies and SQL rows are closed properly, preventing connection leaks.