refactor: apply go fix modernizers for Go 1.26

Automated fixes: interface{} → any, range-over-int, t.Context(),
wg.Go(), strings.SplitSeq, strings.Builder, slices.Contains,
maps helpers, min/max builtins.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-02-22 21:00:17 +00:00
parent bfc855da5b
commit 6970da5c49
15 changed files with 31 additions and 33 deletions

View file

@ -289,7 +289,7 @@ func TestRedisStore_ConcurrentIncrementUsage_Good(t *testing.T) {
var wg sync.WaitGroup
wg.Add(goroutines)
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
err := s.IncrementUsage("agent-1", tokensEach, 1)
@ -313,7 +313,7 @@ func TestRedisStore_ConcurrentModelUsage_Good(t *testing.T) {
var wg sync.WaitGroup
wg.Add(goroutines)
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
err := s.IncrementModelUsage("claude-opus-4-6", tokensEach)
@ -342,7 +342,7 @@ func TestRedisStore_ConcurrentMixed_Good(t *testing.T) {
wg.Add(goroutines * 3)
// Increment usage
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
_ = s.IncrementUsage("agent-1", 100, 1)
@ -350,7 +350,7 @@ func TestRedisStore_ConcurrentMixed_Good(t *testing.T) {
}
// Decrement active jobs
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
_ = s.DecrementActiveJobs("agent-1")
@ -358,7 +358,7 @@ func TestRedisStore_ConcurrentMixed_Good(t *testing.T) {
}
// Return tokens
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
_ = s.ReturnTokens("agent-1", 10)

View file

@ -282,7 +282,7 @@ func TestSQLiteStore_ConcurrentIncrementUsage_Good(t *testing.T) {
var wg sync.WaitGroup
wg.Add(goroutines)
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
err := s.IncrementUsage("agent-1", tokensEach, 1)
@ -306,7 +306,7 @@ func TestSQLiteStore_ConcurrentModelUsage_Good(t *testing.T) {
var wg sync.WaitGroup
wg.Add(goroutines)
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
err := s.IncrementModelUsage("claude-opus-4-6", tokensEach)
@ -335,7 +335,7 @@ func TestSQLiteStore_ConcurrentMixed_Good(t *testing.T) {
wg.Add(goroutines * 3)
// Increment usage
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
_ = s.IncrementUsage("agent-1", 100, 1)
@ -343,7 +343,7 @@ func TestSQLiteStore_ConcurrentMixed_Good(t *testing.T) {
}
// Decrement active jobs
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
_ = s.DecrementActiveJobs("agent-1")
@ -351,7 +351,7 @@ func TestSQLiteStore_ConcurrentMixed_Good(t *testing.T) {
}
// Return tokens
for i := 0; i < goroutines; i++ {
for range goroutines {
go func() {
defer wg.Done()
_ = s.ReturnTokens("agent-1", 10)

View file

@ -53,8 +53,8 @@ var (
// task command flags
var (
taskAutoSelect bool
taskClaim bool
taskAutoSelect bool
taskClaim bool
taskShowContext bool
)
@ -236,7 +236,7 @@ func AddTaskCommands(parent *cli.Command) {
}
func printTaskList(tasks []agentic.Task) {
cli.Print("\n%s\n\n", i18n.T("cmd.ai.tasks.found", map[string]interface{}{"Count": len(tasks)}))
cli.Print("\n%s\n\n", i18n.T("cmd.ai.tasks.found", map[string]any{"Count": len(tasks)}))
for _, task := range tasks {
id := taskIDStyle.Render(task.ID)

View file

@ -101,7 +101,7 @@ var taskCompleteCmd = &cli.Command{
})
if taskCompleteFailed {
cli.Print("%s %s\n", errorStyle.Render(">>"), i18n.T("cmd.ai.task_complete.failed", map[string]interface{}{"ID": taskID}))
cli.Print("%s %s\n", errorStyle.Render(">>"), i18n.T("cmd.ai.task_complete.failed", map[string]any{"ID": taskID}))
} else {
cli.Print("%s %s\n", successStyle.Render(">>"), i18n.T("i18n.done.complete", "task"))
}

View file

@ -101,7 +101,7 @@ func loadEnvFile(path string, cfg *Config) error {
return err
}
for _, line := range strings.Split(content, "\n") {
for line := range strings.SplitSeq(content, "\n") {
line = strings.TrimSpace(line)
// Skip empty lines and comments

View file

@ -142,7 +142,7 @@ func findRelatedCode(task *Task, dir string) ([]FileContent, error) {
}
// Parse matched files
for _, line := range strings.Split(output, "\n") {
for line := range strings.SplitSeq(output, "\n") {
line = strings.TrimSpace(line)
if line == "" || seen[line] {
continue

View file

@ -79,7 +79,7 @@ func TestFindRelatedCode_Good_NoKeywords(t *testing.T) {
task := &Task{
ID: "code-2",
Title: "do it", // too short, all stop words
Title: "do it", // too short, all stop words
Description: "fix the bug in the code",
}
@ -101,7 +101,7 @@ func TestFindRelatedCode_Good_LimitsTo10Files(t *testing.T) {
dir := initGitRepoWithCode(t)
// Create 15 files all containing the keyword "validation".
for i := 0; i < 15; i++ {
for i := range 15 {
name := filepath.Join(dir, "validation_"+string(rune('a'+i))+".go")
content := "package main\n// validation logic\nfunc Validate" + string(rune('A'+i)) + "() {}\n"
err := os.WriteFile(name, []byte(content), 0644)

View file

@ -257,7 +257,7 @@ func TestDispatcher_Dispatch_Good_Concurrent(t *testing.T) {
})
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
for i := range 10 {
wg.Add(1)
go func(n int) {
defer wg.Done()

View file

@ -271,7 +271,7 @@ func TestAllowanceService_NoEventsWithoutEmitter(t *testing.T) {
func drainEvents(em *ChannelEmitter, n int, timeout time.Duration) []Event {
var events []Event
deadline := time.After(timeout)
for i := 0; i < n; i++ {
for range n {
select {
case e := <-em.Events():
events = append(events, e)

View file

@ -119,12 +119,10 @@ func TestChannelEmitter_ConcurrentEmit(t *testing.T) {
ctx := context.Background()
var wg sync.WaitGroup
for i := 0; i < 50; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for range 50 {
wg.Go(func() {
_ = em.Emit(ctx, Event{Type: EventTaskDispatched})
}()
})
}
wg.Wait()

View file

@ -237,7 +237,7 @@ func TestTaskLifecycle_MultipleAgentsConcurrent(t *testing.T) {
wg.Add(1)
go func(aid string) {
defer wg.Done()
for i := 0; i < 10; i++ {
for range 10 {
// Check allowance.
result, err := svc.Check(aid, "")
assert.NoError(t, err)
@ -268,9 +268,9 @@ func TestTaskLifecycle_MultipleAgentsConcurrent(t *testing.T) {
for _, agentID := range agents {
usage, err := store.GetUsage(agentID)
require.NoError(t, err)
assert.Equal(t, int64(1500), usage.TokensUsed) // 10 jobs x 150 tokens
assert.Equal(t, 10, usage.JobsStarted) // 10 starts
assert.Equal(t, 0, usage.ActiveJobs) // all completed
assert.Equal(t, int64(1500), usage.TokensUsed) // 10 jobs x 150 tokens
assert.Equal(t, 10, usage.JobsStarted) // 10 starts
assert.Equal(t, 0, usage.ActiveJobs) // all completed
}
}

View file

@ -275,7 +275,7 @@ func TestRedisRegistry_Concurrent_Good(t *testing.T) {
reg := newTestRedisRegistry(t)
var wg sync.WaitGroup
for i := 0; i < 20; i++ {
for i := range 20 {
wg.Add(1)
go func(n int) {
defer wg.Done()

View file

@ -280,7 +280,7 @@ func TestSQLiteRegistry_Concurrent_Good(t *testing.T) {
reg := newTestSQLiteRegistry(t)
var wg sync.WaitGroup
for i := 0; i < 20; i++ {
for i := range 20 {
wg.Add(1)
go func(n int) {
defer wg.Done()

View file

@ -273,7 +273,7 @@ func TestMemoryRegistry_Concurrent_Good(t *testing.T) {
reg := NewMemoryRegistry()
var wg sync.WaitGroup
for i := 0; i < 20; i++ {
for i := range 20 {
wg.Add(1)
go func(n int) {
defer wg.Done()

View file

@ -56,7 +56,7 @@ type Task struct {
// CreatedAt is when the task was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the task was last modified.
UpdatedAt time.Time `json:"updated_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
// ClaimedBy is the identifier of the agent or developer who claimed the task.
ClaimedBy string `json:"claimed_by,omitempty"`
// ClaimedAt is when the task was claimed.