Skip to content

Commit 9d990f9

Browse files
authored
Merge pull request #1094 from Icinga/go-fix-20260312
tree-wide: Apply go fix
2 parents 957be5d + c5f5754 commit 9d990f9

5 files changed

Lines changed: 8 additions & 12 deletions

File tree

pkg/icingadb/delta_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ func TestDelta(t *testing.T) {
135135
// Log ID mapping to allow easier debugging in case of failures.
136136
t.Logf("ID=%d(%s) Test=%s SendOrder=%s",
137137
id, testDeltaMakeIdOrChecksum(id).String(), test.Name, sendOrder.Name)
138-
wg.Add(1)
139-
go func() {
140-
defer wg.Done()
138+
wg.Go(func() {
141139
sendOrder.Send(id, test, chActual, chDesired)
142-
}()
140+
})
143141

144142
if test.Create != 0 {
145143
expectedCreate[id] = test.Create

pkg/icingadb/history/sla.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
var slaStateStructify = structify.MakeMapStructifier(
14-
reflect.TypeOf((*history.SlaHistoryState)(nil)).Elem(),
14+
reflect.TypeFor[history.SlaHistoryState](),
1515
"json",
1616
contracts.SafeInit)
1717

pkg/icingadb/history/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func userNotificationStage(ctx context.Context, s Sync, key string, in <-chan re
331331
}
332332

333333
structifier := structify.MakeMapStructifier(
334-
reflect.TypeOf((*NotificationHistory)(nil)).Elem(),
334+
reflect.TypeFor[NotificationHistory](),
335335
"structify",
336336
contracts.SafeInit)
337337

pkg/icingaredis/utils_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ func TestSetChecksums(t *testing.T) {
240240
t.Run(fmt.Sprint(concurrency), func(t *testing.T) {
241241
for _, l := range latencies {
242242
t.Run(l.name, func(t *testing.T) {
243-
ctx, cancel := context.WithCancel(context.Background())
244-
defer cancel()
243+
ctx := t.Context()
245244

246245
input := make(chan database.Entity, 1)
247246
go func() {
@@ -311,8 +310,7 @@ func TestSetChecksums(t *testing.T) {
311310

312311
for _, concurrency := range []int{0, -1, -2, -30} {
313312
t.Run(fmt.Sprint(concurrency), func(t *testing.T) {
314-
ctx, cancel := context.WithCancel(context.Background())
315-
defer cancel()
313+
ctx := t.Context()
316314

317315
input := make(chan database.Entity, 1)
318316
input <- nil

pkg/notifications/notifications.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ func (client *Client) Submit(entity database.Entity) bool {
430430
// This loop allows resubmitting an event if the rules have changed. The first try would be the rule update, the
431431
// second try would be the resubmit, and the third try would be for bad luck, e.g., when a second rule update just
432432
// crept in between. If there are three subsequent rule updates, something is wrong.
433-
for try := 0; try < 3; try++ {
433+
for range 3 {
434434
eventRuleIds, err := client.evaluateRulesForObject(
435435
client.ctx,
436436
metaHistory.HostId,
@@ -484,7 +484,7 @@ func (client *Client) SyncExtraStages() map[string]history.StageFunc {
484484
}
485485

486486
sorterCallbackFn := func(msg redis.XMessage, key string) bool {
487-
makeEntity := func(key string, values map[string]interface{}) (database.Entity, error) {
487+
makeEntity := func(key string, values map[string]any) (database.Entity, error) {
488488
structPtr, ok := syncKeyStructPtrs[key]
489489
if !ok {
490490
return nil, fmt.Errorf("key is not part of keyStructPtrs")

0 commit comments

Comments
 (0)