mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-03 19:41:34 +02:00
all: don't rebind variables in for loops
See https://tip.golang.org/wiki/LoopvarExperiment#does-this-mean-i-dont-have-to-write-x--x-in-my-loops-anymore Updates https://github.com/tailscale/tailscale/issues/11058 Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
parent
8b3e88cd09
commit
002ecb78d0
@ -196,7 +196,6 @@ func TestComplete(t *testing.T) {
|
||||
|
||||
// Run the tests.
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
name := strings.Join(test.args, "␣")
|
||||
if test.showFlags {
|
||||
name += "+flags"
|
||||
|
@ -1073,7 +1073,6 @@ func (c *Client) runHTTPOnlyChecks(ctx context.Context, last *Report, rs *report
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
rg := rg
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
node := rg.Nodes[0]
|
||||
|
@ -33,7 +33,6 @@ func TestInQemu(t *testing.T) {
|
||||
}
|
||||
inCI := cibuild.On()
|
||||
for _, arch := range arches {
|
||||
arch := arch
|
||||
t.Run(arch.Goarch, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
qemuUser := "qemu-" + arch.Qarch
|
||||
|
@ -56,7 +56,6 @@ func TestClockWithDefinedStartTime(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
clock := NewClock(ClockOpts{
|
||||
@ -118,7 +117,6 @@ func TestClockWithDefaultStartTime(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
clock := NewClock(ClockOpts{
|
||||
@ -277,7 +275,6 @@ func TestClockSetStep(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
clock := NewClock(ClockOpts{
|
||||
@ -426,7 +423,6 @@ func TestClockAdvance(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
clock := NewClock(ClockOpts{
|
||||
@ -876,7 +872,6 @@ func TestSingleTicker(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var realTimeClockForTestClock tstime.Clock
|
||||
@ -1377,7 +1372,6 @@ func TestSingleTimer(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var realTimeClockForTestClock tstime.Clock
|
||||
@ -1911,7 +1905,6 @@ func TestClockFollowRealTime(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
realTimeClock := NewClock(tt.realTimeClockOpts)
|
||||
@ -2364,7 +2357,6 @@ func TestAfterFunc(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var realTimeClockForTestClock tstime.Clock
|
||||
@ -2468,7 +2460,6 @@ func TestSince(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
clock := NewClock(ClockOpts{
|
||||
|
@ -333,7 +333,6 @@ func TestOneNodeUpAuth(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
|
||||
for _, useSeamlessKeyRenewal := range []bool{true, false} {
|
||||
tt := tt // subtests are run in parallel, rebind tt
|
||||
t.Run(fmt.Sprintf("%s-seamless-%t", tt.name, useSeamlessKeyRenewal), func(t *testing.T) {
|
||||
tstest.Parallel(t)
|
||||
|
||||
|
@ -836,7 +836,6 @@ func (c *Conn) maybeCloseDERPsOnRebind(okayLocalIPs []netip.Prefix) {
|
||||
c.closeOrReconnectDERPLocked(regionID, "rebind-default-route-change")
|
||||
continue
|
||||
}
|
||||
regionID := regionID
|
||||
dc := ad.c
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
|
@ -1898,7 +1898,6 @@ func (ns *Impl) ExpVar() expvar.Var {
|
||||
{"option_unknown_received", ipStats.OptionUnknownReceived},
|
||||
}
|
||||
for _, metric := range ipMetrics {
|
||||
metric := metric
|
||||
m.Set("counter_ip_"+metric.name, expvar.Func(func() any {
|
||||
return readStatCounter(metric.field)
|
||||
}))
|
||||
@ -1925,7 +1924,6 @@ func (ns *Impl) ExpVar() expvar.Var {
|
||||
{"errors", fwdStats.Errors},
|
||||
}
|
||||
for _, metric := range fwdMetrics {
|
||||
metric := metric
|
||||
m.Set("counter_ip_forward_"+metric.name, expvar.Func(func() any {
|
||||
return readStatCounter(metric.field)
|
||||
}))
|
||||
@ -1969,7 +1967,6 @@ func (ns *Impl) ExpVar() expvar.Var {
|
||||
{"forward_max_in_flight_drop", tcpStats.ForwardMaxInFlightDrop},
|
||||
}
|
||||
for _, metric := range tcpMetrics {
|
||||
metric := metric
|
||||
m.Set("counter_tcp_"+metric.name, expvar.Func(func() any {
|
||||
return readStatCounter(metric.field)
|
||||
}))
|
||||
@ -1996,7 +1993,6 @@ func (ns *Impl) ExpVar() expvar.Var {
|
||||
{"checksum_errors", udpStats.ChecksumErrors},
|
||||
}
|
||||
for _, metric := range udpMetrics {
|
||||
metric := metric
|
||||
m.Set("counter_udp_"+metric.name, expvar.Func(func() any {
|
||||
return readStatCounter(metric.field)
|
||||
}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user