Skip to content
Agentmart
Submit a tool

go-style

Go coding conventions, error handling, interface design, and idiomatic patterns.

Skill by els0r

IndexedMIT★ 1
Write a review

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/els0r-go-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.

We use your email only for this newsletter. Privacy

About

Go coding conventions, error handling, interface design, and idiomatic patterns. Use when writing, reviewing, refactoring, or discussing Go code. Fires alongside coding-style — do not repeat cross-language rules.

Use cases: design, writing

No 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/go-style

What's inside

Skill name
go-style
Description
Go coding conventions, error handling, interface design, and idiomatic patterns. Use when writing, reviewing, refactoring, or discussing Go code. Fires alongside coding-style — do not repeat cross-language rules.
License
MIT
Instructions
132 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Go Coding Style

Cross-language principles (never-nesting, naming, restraint) live in `coding-style`. This file covers Go-specific idioms only.

## Never Nesting — Go Idiom

Guard clauses with early return. `continue` in loops. This is the Go spelling of the universal rule.

```go
// ✅
func checkA(str string) bool {
    if str == "" {
        return false
    }
    for _, char := range str {
        if char == ' ' || char == '\t' || char == '\n' {
            continue
        }
        if char == 'A' || char == 'a' {
            return true
        }
    }
    return false
}
```

## Error Handling

Handle all errors. Wrap with context using `%w`. No naked returns.

```go
// ✅ wrap with context
if err := repo.SaveUser(ctx, user); err != nil {
    return fmt.Errorf("save user %s: %w", user.ID, err)
}

// ❌ context lost
if err := repo.SaveUser(ctx, user); err != nil {
    return err
}
```

Sentinel errors for known conditions. Custom types when callers need structured data.

```go
var (
    ErrNotFound     = errors.New("resource not found")
    ErrUnauthorized = errors.New("unauthorized")
)

// check with errors.Is / errors.As — never string matching
```

Acceptable exception: best-effort cleanup with explicit discard.

```go
_ = writer.Close()
```

## Zero-Value Design

Types must be usable at zero value. No constructor-required initialization.

```go
// ✅ zero value works
type Counter struct {
    mu    sync.Mutex
    count int
}

// ❌ nil map panic
type BadCounter struct {
    counts map[string]int
}
```

## Interface Design

- Accept interfaces, return structs.
- Single-method interfaces preferred. Compose when needed.
- Define interfaces at the consumer, not the implementor.

```go
// consumer owns the interface
package service

type UserStore interface {
    GetUser(id string) (*User, error)
}

type Service struct {
    store UserStore
}
```

## Functional Options

Use for constructors with optional configuration.

```go
type Option func(*Server)

func WithTimeout(d time.Duration) Option {
    return func(s *Server) { s.timeout = d }
}

func NewServer(addr string, opts ...Option) *Server {
    s := &Server{addr: addr, timeout: 30 * time.Second}
    for _, opt := range opts {
        opt(s)
    }
    return s
}
```

## Package Organization

- Short, lowercase names — no underscores.
- `internal/` for packages not intended for external import.

From els0r/skills, MIT.

More from els0r/skills

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
May 20, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from els0r

Cite this page

go-style skill. Agent Mart. https://agentmart.dev/skills/els0r-go-style (last updated 2026-10-24)