golang-code-style
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt.
Skill by samber
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hellopoisonx-golang-code-style
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: documents, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/golang-code-style
Tools it pre-approves 9
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
ReadEditWriteGlobGrepBash(go:*)Bash(golangci-lint:*)Bash(git:*)Agent
What's inside
- Skill name
golang-code-style- Description
- Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See `samber/cc-skills-golang@golang-naming` skill), linter configuration (→ See `samber/cc-skills-golang@golang-lint` skill), or doc comments (→ See `samber/cc-skills-golang@golang-documentation` skill).
- License
- MIT
- Compatibility
- Designed for Claude Code or similar AI coding agents, and for projects using Golang.
- Allowed tools
- Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent
- Metadata
- author: samber · version: 1.2.0
- Instructions
- 219 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves some shell commands
Files (3)
- SKILL.md
- evals.json · evals/
- details.md · references/
SKILL.md (first lines)
> **Community default.** A company skill that explicitly supersedes `samber/cc-skills-golang@golang-code-style` skill takes precedence.
# Go Code Style
Style rules that require human judgment — linters handle formatting, this skill handles clarity. For naming see `samber/cc-skills-golang@golang-naming` skill; for design patterns see `samber/cc-skills-golang@golang-design-patterns` skill; for struct/interface design see `samber/cc-skills-golang@golang-structs-interfaces` skill.
> "Clear is better than clever." — Go Proverbs
When ignoring a rule, add a comment to the code.
## Line Length & Breaking
No rigid line limit, but lines beyond ~120 characters MUST be broken. Break at **semantic boundaries**, not arbitrary column counts. Function calls with 4+ arguments MUST use one argument per line — even when the prompt asks for single-line code:
```go
// Good — each argument on its own line, closing paren separate
mux.HandleFunc("/api/users", func(w http.ResponseWriter, r *http.Request) {
handleUsers(
w,
r,
serviceName,
cfg,
logger,
authMiddleware,
)
})
```
When a function signature is too long, the real fix is often **fewer parameters** (use an options struct) rather than better line wrapping. For multi-line signatures, put each parameter on its own line.
## Variable Declarations
SHOULD use `:=` for non-zero values, `var` for zero-value initialization. The form signals intent: `var` means "this starts at zero."
```go
var count int // zero value, set later
name := "default" // non-zero, := is appropriate
var buf bytes.Buffer // zero value is ready to use
```
### Slice & Map Initialization
Slices and maps MUST be initialized explicitly, never nil. Nil maps panic on write; nil slices serialize to `null` in JSON (vs `[]` for empty slices), surprising API consumers.
```go
users := []User{} // always initialized
m := map[string]int{} // always initialized
users := make([]User, 0, len(ids)) // preallocate when capacity is known
m := make(map[string]int, len(items)) // preallocate when size is known
```
Do not preallocate speculatively — `make([]T, 0, 1000)` wastes memory when the common case is 10 items.
### Composite Literals
Composite literals MUST use field names — positional fields break when the type adds or reorders fields:
```go
srv := &http.Server{
Addr: ":8080",
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}
```
## Control Flow
### Reduce Nesting
Errors and edge cases MUST be handled first (early return). Keep the happy path at minimal indentation:
```go
func process(data []byte) (*Result, error) {
if len(data) == 0 {
return nil, errors.New("empty data")
}
parsed, err := parse(data)
if err != nil {
return nil, fmt.Errorf("parsing: %w", err)
}
return transform(parsed), nil
}
```
### Eliminate Unnecessary `else`
When the `if` body ends with `return`/`break`/`continue`, the `else` MUST be dropped. Use default-then-override for simple assignments — assign a default, then override with independent conditions or a `switch`:
```go
// Good — default-then-override with switch (cleanest for mutually exclusive overrides)
level := slog.LevelInfo
switch {
case debug:
level = slog.LevelDebug
case verbose:
level = slog.LevelWarn
}
// Bad — else-if chain hides that there's a default
if debug {
level = slog.LevelDebug
} else if verbose {
level = slog.LevelWarn
} else {
level = slog.LevelInfo
}
```
### Complex Conditions & Init Scope
When an `if` condition has 3+ operands, MUST extract into named booleans — a wall of `||` is unreadable and hides business logic. Keep expensive checks inline for short-circuit benefit. [Details](./references/details.md)
```go
// Good — named booleans make intent clear
isAdmin := user.Role == RoleAdmin
isOwner := resource.OwnerID == user.ID
isPublicVerified := resource.IsPublic && user.IsVerifiedFrom hellopoisonx/aim, MIT.
More from hellopoisonx/aim
- 0.534score
golang-concurrency
samber
Golang concurrency patterns.
SkillCFreshness: C★ 5Claude Code +9 - 0.534score
golang-context
samber
Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values…
SkillCFreshness: C★ 5Claude Code +9 - 0.534score
golang-continuous-integration
samber
CI/CD pipeline configuration using GitHub Actions for Golang projects — testing, linting, SAST, security scanning, code coverage, Dependabot, Renovate…
SkillCFreshness: C★ 5Claude Code - 0.534score
golang-benchmark
samber
Golang benchmarking, profiling, and performance measurement.
SkillCFreshness: C★ 5Claude Code - 0.529score
golang-cli
samber
Golang CLI application development.
SkillCFreshness: C★ 5Claude Code +9 - 0.526score
aim-dev-tool
hellopoisonx
AIM 开发测试工具(dev-tool)。Python CLI,覆盖 gateway 全部 REST 端点与 WebSocket 帧协议,支持多 profile 多用户并行测试、并发压测。当需要调试 REST/WS 接口、运行集成测试、压力测试、或新增命令时使用。
SkillCFreshness: C★ 5Claude Code +9 - 0.524score
aim-docker-datastore
hellopoisonx
AIM 本地 Docker 数据存储运维 Skill。Use when the user asks to inspect, connect to, query, debug, or verify Docker Compose Kafka, Redis, or PostgreSQL in this project…
SkillCFreshness: C★ 5Claude Code +9 - 0.523score
aim-repo-mapping
hellopoisonx
aim 仓库导航 Skill。用于快速判断需求应该落到哪个业务域、哪个控制器、哪个工作流或哪个配置文件;当需求入口不清晰、需要先找模块边界、接口总览、运行入口或改动影响面时使用。
SkillCFreshness: C★ 5Claude Code +9 - 0.523score
aim-ws-token-management
hellopoisonx
WebSocket 连接 Token 生命周期管理。覆盖 Token 过期导致 WS 断连的排查与修复、JWT TTL 配置链路、WSClient 自动刷新机制、压测长跑场景下的 Token 续期策略。
SkillCFreshness: C★ 5Claude Code +9 - 0.523score
aim-database-migration
hellopoisonx
AIM 数据库迁移规范与 Docker Compose 集成。当修改 migration SQL 文件、新增迁移、修改 docker-compose.yaml 的 migrate 服务、或排查迁移失败时使用。
SkillCFreshness: C★ 5Claude Code +9 - 0.520score
aim-shared-domain
hellopoisonx
aim 的进程内共享包域。对应 `app/shared` 模块。
SkillCFreshness: C★ 5Claude Code +9 - 0.520score
aim-proto-domain
hellopoisonx
aim 的 Protobuf 协议域。定义跨端/跨服务线缆协议。对应 `shared/proto` 目录。
SkillCFreshness: C★ 5Claude Code +9
Signals
- Stars
- 5
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 26, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.2.0
- License
- MIT
- Repository
- github.com/hellopoisonx/aim
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from samber
- 0.563score
golang-design-patterns
samber
Idiomatic Golang design patterns — functional options, constructors, error flow and cascading, resource management and lifecycle, graceful shutdown…
SkillBFreshness: B★ 2Claude Code +9 - 0.563score
golang-performance
samber
Golang performance optimization patterns and methodology - if X bottleneck, then apply Y.
SkillBFreshness: B★ 2Claude Code - 0.563score
golang-security
samber
Security best practices and vulnerability prevention for Golang.
SkillBFreshness: B★ 2Claude Code - 0.563score
golang-testing
samber
Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak…
SkillBFreshness: B★ 2Claude Code +9 - 0.563score
golang-documentation
samber
Comprehensive documentation guide for Golang projects, covering godoc comments, README, CONTRIBUTING, CHANGELOG, Go Playground, Example tests, API docs, and…
SkillBFreshness: B★ 2Claude Code - 0.534score
golang-benchmark
samber
Golang benchmarking, profiling, and performance measurement.
SkillCFreshness: C★ 5Claude Code
Cite this page
golang-code-style skill. Agent Mart. https://agentmart.dev/skills/hellopoisonx-golang-code-style (last updated 2026-10-24)