Use descriptive, semantically clear names that follow consistent patterns throughout the codebase. Names should convey purpose and follow established conventions.

Key guidelines:

  1. Use descriptive names that reflect purpose

    // Good lockCtx, lockTimeoutCancel := context.WithTimeout(ctx, onlineDDL.CutOverThreshold) defer lockTimeoutCancel() ```

  2. Follow established naming patterns

    // Good func (session *SafeSession) IsTxErrorBlockNextQueries() bool ```

  3. Avoid redundancy in names

    // Good type options struct {…}

    // Bad type myShardActionInfo interface {…}

    // Good type shardActionInfo interface {…} ```

  4. Be consistent with delimiters and formatting

    // 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) ```

  5. Prefer clarity over brevity

    // 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.