treewide: initialize empty structs with var
Change-Id: I72d3993eaf5fe57c77b1dda8218e36a8cc11813d
Reviewed-on: https://review.monogon.dev/c/monogon/+/3108
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/metropolis/pkg/event/etcd/etcd_test.go b/metropolis/pkg/event/etcd/etcd_test.go
index c6d50b1..bd96363 100644
--- a/metropolis/pkg/event/etcd/etcd_test.go
+++ b/metropolis/pkg/event/etcd/etcd_test.go
@@ -63,7 +63,7 @@
// it starts the watcher. This is used to test potential race conditions
// present between these two steps.
func setRaceWg[T any](w event.Watcher[T]) *sync.WaitGroup {
- wg := sync.WaitGroup{}
+ var wg sync.WaitGroup
w.(*watcher[T]).testRaceWG = &wg
return &wg
}
@@ -72,7 +72,7 @@
// thie WG after an etcd watch channel is created. This is used in tests to
// ensure that the watcher is fully created before it is tested.
func setSetupWg[T any](w event.Watcher[T]) *sync.WaitGroup {
- wg := sync.WaitGroup{}
+ var wg sync.WaitGroup
w.(*watcher[T]).testSetupWG = &wg
return &wg
}
diff --git a/metropolis/pkg/event/memory/example_test.go b/metropolis/pkg/event/memory/example_test.go
index 583650c..1ae12c6 100644
--- a/metropolis/pkg/event/memory/example_test.go
+++ b/metropolis/pkg/event/memory/example_test.go
@@ -82,7 +82,7 @@
defer ctxC()
// Create a fake NetworkService.
- ns := NetworkService{}
+ var ns NetworkService
// Run an /etc/hosts updater. It will watch for updates from the NetworkService
// about the current IP address of the node.
diff --git a/metropolis/pkg/event/memory/memory_test.go b/metropolis/pkg/event/memory/memory_test.go
index 80ac575..eec0a37 100644
--- a/metropolis/pkg/event/memory/memory_test.go
+++ b/metropolis/pkg/event/memory/memory_test.go
@@ -71,7 +71,7 @@
Sync: true,
}
values := make(chan int, 100)
- wg := sync.WaitGroup{}
+ var wg sync.WaitGroup
wg.Add(1)
go func() {
ctx := context.Background()