Skip to content

Commit

Permalink
Modernize the codebase
Browse files Browse the repository at this point in the history
Signed-off-by: Your Name <[email protected]>
  • Loading branch information
akagami-harsh committed Feb 7, 2025
1 parent 10a6916 commit 271b807
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go/cmd/rulesctl/cmd/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fails selects."
The list of valid plan types that can be used follows:
`)
for i := 0; i < int(planbuilder.NumPlans); i++ {
for i := range int(planbuilder.NumPlans) {
fmt.Printf(" - %v\n", planbuilder.PlanType(i).String())
}
}
4 changes: 2 additions & 2 deletions go/cmd/vtclient/cli/vtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func execMulti(ctx context.Context, db *sql.DB, sql string) (*results, error) {
isThrottled := qps > 0

start := time.Now()
for i := 0; i < parallel; i++ {
for range parallel {
wg.Add(1)

go func() {
Expand All @@ -232,7 +232,7 @@ func execMulti(ctx context.Context, db *sql.DB, sql string) (*results, error) {
ticker = time.NewTicker(tickDuration)
}

for j := 0; j < count; j++ {
for range count {
var qr *results
var err error
if isDML {
Expand Down
3 changes: 1 addition & 2 deletions go/fileutil/wildcards.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ package fileutil
// where we detect a bad pattern, we return 'true', and let the path.Match
// function find it.
func HasWildcard(path string) bool {
for i := 0; i < len(path); i++ {
for i := range len(path) {
switch path[i] {
case '\\':
if i+1 >= len(path) {
return true
}
i++
case '*', '?', '[':
return true
}
Expand Down
2 changes: 1 addition & 1 deletion go/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (history *History) Records() []any {
records = append(records, history.records[:history.next]...)

// In place reverse.
for i := 0; i < history.length/2; i++ {
for i := range history.length / 2 {
records[i], records[history.length-i-1] = records[history.length-i-1], records[i]
}

Expand Down
10 changes: 5 additions & 5 deletions go/mysql/binlog_event_rbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (ev binlogEvent) Rows(f BinlogFormat, tm *TableMap) (Rows, error) {

// For PartialUpdateRowsEvents, we need to know how many JSON columns there are.
if ev.Type() == ePartialUpdateRowsEvent {
for c := 0; c < int(columnCount); c++ {
for c := range int(columnCount) {
if tm.Types[c] == binlog.TypeJSON {
numJSONColumns++
}
Expand All @@ -345,7 +345,7 @@ func (ev binlogEvent) Rows(f BinlogFormat, tm *TableMap) (Rows, error) {
// Get the identify values.
startPos := pos
valueIndex := 0
for c := 0; c < int(columnCount); c++ {
for c := range int(columnCount) {
if !result.IdentifyColumns.Bit(c) {
// This column is not represented.
continue
Expand Down Expand Up @@ -386,7 +386,7 @@ func (ev binlogEvent) Rows(f BinlogFormat, tm *TableMap) (Rows, error) {
// Get the values.
startPos := pos
valueIndex := 0
for c := 0; c < int(columnCount); c++ {
for c := range int(columnCount) {
if !result.DataColumns.Bit(c) {
// This column is not represented.
continue
Expand Down Expand Up @@ -426,7 +426,7 @@ func (rs *Rows) StringValuesForTests(tm *TableMap, rowIndex int) ([]string, erro
jsonIndex := 0
data := rs.Rows[rowIndex].Data
pos := 0
for c := 0; c < rs.DataColumns.Count(); c++ {
for c := range rs.DataColumns.Count() {
if !rs.DataColumns.Bit(c) {
continue
}
Expand Down Expand Up @@ -470,7 +470,7 @@ func (rs *Rows) StringIdentifiesForTests(tm *TableMap, rowIndex int) ([]string,
valueIndex := 0
data := rs.Rows[rowIndex].Identify
pos := 0
for c := 0; c < rs.IdentifyColumns.Count(); c++ {
for c := range rs.IdentifyColumns.Count() {
if !rs.IdentifyColumns.Bit(c) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/collations/colldata/multibyte.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *Collation_multibyte) Collate(left, right []byte, isPrefix bool) int {
cmpLen := min(len(left), len(right))
cs := c.charset
sortOrder := c.sort
for i := 0; i < cmpLen; i++ {
for i := range cmpLen {
sortL, sortR := left[i], right[i]
if sortL > 127 {
if sortL != sortR {
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func checkQueryInternal(t *testing.T, query string, sConn, cConn *Conn, result *
warnings: warningCount,
}

for i := 0; i < count; i++ {
for i := range count {
kontinue := sConn.handleNextCommand(&handler)
require.True(t, kontinue, "error handling command: %d", i)

Expand Down
2 changes: 1 addition & 1 deletion go/mysql/streaming_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *Conn) ExecuteStreamFetch(query string) (err error) {

// Read column headers. One packet per column.
// Build the fields.
for i := 0; i < colNumber; i++ {
for i := range colNumber {
fieldsPointers[i] = &fields[i]
if err := c.readColumnDefinition(fieldsPointers[i], i); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func main() {
if *runCount > 1 {
var dup []*Test
for _, t := range tests {
for i := 0; i < *runCount; i++ {
for i := range *runCount {
// Make a copy, since they're pointers.
test := *t
test.runIndex = i
Expand Down Expand Up @@ -479,7 +479,7 @@ func main() {
}()

// Start the requested number of parallel runners.
for i := 0; i < *parallel; i++ {
for range *parallel {
wg.Add(1)
go func() {
defer wg.Done()
Expand Down

0 comments on commit 271b807

Please sign in to comment.