go1.24: fix lint, unit and system tests

- development env: base on debian trixie with go1.24
- lint: run with default config
- fix lint errors
- fix unit tests
- fix system test
This commit is contained in:
André Roth
2025-04-12 17:53:48 +02:00
parent ae5379d84a
commit f7057a9517
117 changed files with 803 additions and 727 deletions

View File

@@ -31,7 +31,7 @@ func NewList() *List {
wgTasks: make(map[int]*sync.WaitGroup),
wg: &sync.WaitGroup{},
usedResources: NewResourcesSet(),
queue: make(chan *Task, 0),
queue: make(chan *Task),
queueWg: &sync.WaitGroup{},
queueDone: make(chan bool),
}
@@ -123,11 +123,11 @@ func (list *List) DeleteTaskByID(ID int) (Task, error) {
return *task, nil
}
return *task, fmt.Errorf("Task with id %v is still in state=%d", ID, task.State)
return *task, fmt.Errorf("task with id %v is still in state=%d", ID, task.State)
}
}
return Task{}, fmt.Errorf("Could not find task with id %v", ID)
return Task{}, fmt.Errorf("could not find task with id %v", ID)
}
// GetTaskByID returns task with given id
@@ -142,7 +142,7 @@ func (list *List) GetTaskByID(ID int) (Task, error) {
}
}
return Task{}, fmt.Errorf("Could not find task with id %v", ID)
return Task{}, fmt.Errorf("could not find task with id %v", ID)
}
// GetTaskOutputByID returns standard output of task with given id
@@ -236,14 +236,14 @@ func (list *List) WaitForTaskByID(ID int) (Task, error) {
wgTask, ok := list.wgTasks[ID]
list.Unlock()
if !ok {
return Task{}, fmt.Errorf("Could not find task with id %v", ID)
return Task{}, fmt.Errorf("could not find task with id %v", ID)
}
wgTask.Wait()
return list.GetTaskByID(ID)
}
// GetTaskError returns the Task error for a given id
// GetTaskErrorByID returns the Task error for a given id
func (list *List) GetTaskErrorByID(ID int) (error, error) {
task, err := list.GetTaskByID(ID)

View File

@@ -21,7 +21,7 @@ func (s *ListSuite) TestList(c *check.C) {
return nil, nil
})
c.Assert(err, check.IsNil)
list.WaitForTaskByID(task.ID)
_, _ = list.WaitForTaskByID(task.ID)
tasks := list.GetTasks()
c.Assert(len(tasks), check.Equals, 1)
@@ -38,7 +38,7 @@ func (s *ListSuite) TestList(c *check.C) {
return nil, errors.New("Task failed")
})
c.Assert(err, check.IsNil)
list.WaitForTaskByID(task.ID)
_, _ = list.WaitForTaskByID(task.ID)
tasks = list.GetTasks()
c.Assert(len(tasks), check.Equals, 2)

View File

@@ -107,21 +107,21 @@ func (t *Output) SetBar(_ int) {
// Printf does printf in a safe manner
func (t *Output) Printf(msg string, a ...interface{}) {
t.WriteString(fmt.Sprintf(msg, a...))
_, _ = t.WriteString(fmt.Sprintf(msg, a...))
}
// Print does printf in a safe manner
func (t *Output) Print(msg string) {
t.WriteString(msg)
_, _ = t.WriteString(msg)
}
// ColoredPrintf does printf in a safe manner + newline
// currently are no colors supported.
func (t *Output) ColoredPrintf(msg string, a ...interface{}) {
t.WriteString(fmt.Sprintf(msg+"\n", a...))
_, _ = t.WriteString(fmt.Sprintf(msg+"\n", a...))
}
// PrintfStdErr does printf but in safe manner to output
func (t *Output) PrintfStdErr(msg string, a ...interface{}) {
t.WriteString(fmt.Sprintf(msg, a...))
_, _ = t.WriteString(fmt.Sprintf(msg, a...))
}