Use descriptive, semantically clear names that follow consistent patterns throughout the codebase. Names should convey purpose and follow established conventions.
Key guidelines:
// Good lockCtx, lockTimeoutCancel := context.WithTimeout(ctx, onlineDDL.CutOverThreshold) defer lockTimeoutCancel() ```
Is
prefix for boolean getter methods// Good func (session *SafeSession) IsTxErrorBlockNextQueries() bool ```
// Good type options struct {…}
// Bad type myShardActionInfo interface {…}
// Good type shardActionInfo interface {…} ```
// Good fs.StringVar(&flagMysqlBindAddress, “mycnf-mysql-bin-address”, …)
// Bad - function splits SQL but is called “parse” func parseSQL(querySQL …string) ([]string, error)
// Good - name matches actual behavior func splitSQL(querySQL …string) ([]string, error) ```
json:"-"
// Good
RetryCount int json:"-"
```
Following these naming conventions improves code readability, reduces cognitive load during reviews, and helps prevent bugs caused by confusion over variable or function purposes.
Enter the URL of a public GitHub repository