Go has established naming conventions for interfaces, particularly single-method interfaces. According to the official Go documentation "Effective
Go", single-method interfaces should be named by taking the method name and adding an "-er" suffix or similar modification to create an agent
noun.
This convention serves several important purposes:
- Predictability: Developers can quickly understand what an interface does just by looking at its name
- Consistency: Following established patterns makes codebases more uniform and easier to navigate
- Readability: Agent nouns like
Reader, Writer, Formatter immediately convey the
interface’s purpose
- Community standards: Adhering to Go conventions makes code more familiar to other Go developers
When interfaces don’t follow this pattern, they become less intuitive. For example, FileRead doesn’t immediately suggest it’s an
interface, while Reader clearly indicates both the action and that it’s likely an interface following Go conventions.
What is the potential impact?
Not following Go naming conventions reduces code readability and makes it harder for developers to understand the codebase quickly. It can also
make the code feel inconsistent with standard Go libraries and community practices, potentially confusing team members who expect conventional naming
patterns.