Fundamentals 4 min read

Why Go Uses ‘er’ and ‘able’ Suffixes: Naming Conventions Explained

This article explores Go's naming conventions, focusing on the logical use of the “er” and “able” suffixes in interfaces and types, and explains how following these guidelines improves code readability, consistency, and expressive power.

Ops Development & AI Practice
Ops Development & AI Practice
Ops Development & AI Practice
Why Go Uses ‘er’ and ‘able’ Suffixes: Naming Conventions Explained

Interface Naming with er Suffix

Go interfaces are typically named with the er suffix to describe the single method they expose. The name directly conveys the behavior that an implementation must provide.

type Reader interface {
    Read(p []byte) (n int, err error)
}

type Writer interface {
    Write(p []byte) (n int, err error)
}

type Closer interface {
    Close() error
}

Capability Naming with able Suffix

When an interface represents a broader capability rather than a single action, the able suffix is sometimes used. It signals that a type possesses a particular ability, such as being serializable or convertible.

type Stringer interface {
    String() string
}

type JSONMarshaler interface {
    MarshalJSON() ([]byte, error)
}

Guidelines for Choosing Names

Single‑method interfaces : Prefer the er suffix (e.g., Reader, Writer, Closer).

Capability interfaces : Use able when the interface groups several related methods or expresses a property (e.g., Stringer, JSONMarshaler).

Brevity vs. clarity : If a concise name already conveys intent, omit the suffix. Go’s philosophy favors short, expressive names.

Consistency : Apply the same convention across a codebase to aid readability and onboarding.

Benefits of Consistent Naming

Improved readability : Developers can infer an interface’s purpose from its name without inspecting the method set.

Enhanced maintainability : Uniform naming reduces cognitive load during code reviews and refactoring.

Clear intent : Suffixes act as a lightweight form of documentation, making API contracts explicit.

Practical Application

When designing a new package, start by asking whether the interface represents a single action ( er) or a broader capability ( able). Draft the interface, then evaluate the name:

Does the name describe the behavior succinctly?

Is the er or able suffix adding clarity or redundancy?

Can the interface be merged with an existing one to avoid unnecessary proliferation?

Following these steps helps keep the API surface small while preserving expressive power.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Gonaming conventionscode readabilityInterface Design
Ops Development & AI Practice
Written by

Ops Development & AI Practice

DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.