In Go, using 'Get' prefixes in function and method names is considered redundant and goes against established naming conventions. The Go community
follows the principle that functions returning something should be given noun-like names, starting directly with the noun rather than prefixing it
with 'Get'.
This convention exists because the function signature already makes it clear that something is being returned. Adding 'Get' creates unnecessary
verbosity without adding meaningful information. For example, func (c *Config) GetJobName() is less idiomatic than func (c *Config)
JobName().
The 'Get' prefix pattern comes from other programming languages like Java, where getters and setters are common. However, Go’s philosophy
emphasizes simplicity and conciseness, making such prefixes unnecessary.
Following this convention makes code more readable and consistent with the broader Go ecosystem, including the standard library and most
open-source Go projects.
What is the potential impact?
Using 'Get' prefixes in function names reduces code readability and makes the codebase inconsistent with Go naming conventions. While this doesn’t
cause functional issues, it can:
- Make the code appear less idiomatic to Go developers
- Reduce maintainability as the naming doesn’t follow community standards
- Create inconsistency when working with standard library and third-party packages that follow Go conventions
- Make function names unnecessarily verbose