When designing or modifying APIs, ensure they follow established patterns and conventions within the codebase rather than introducing inconsistent approaches. This includes maintaining symmetrical interfaces, preserving backward compatibility when possible, and using consistent parameter types across similar functions.
When designing or modifying APIs, ensure they follow established patterns and conventions within the codebase rather than introducing inconsistent approaches. This includes maintaining symmetrical interfaces, preserving backward compatibility when possible, and using consistent parameter types across similar functions.
Key principles:
Example from the codebase:
// Instead of exposing non-exported types in public APIs:
func (a *Annotations) Add(err annoErr) Annotations // โ Inconsistent
// Keep the established API and handle internally:
func (a *Annotations) Add(err error) Annotations { // โ
Consistent
// Handle type assertions internally
}
This approach reduces friction for API consumers, maintains predictable interfaces, and ensures that related functionality follows similar patterns throughout the codebase.
Enter the URL of a public GitHub repository