Skip to content

Commit c55e44a

Browse files
committed
go fix ./...
to modernize
1 parent 277298d commit c55e44a

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

filter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func runInternalFilter(ctx context.Context, src io.Reader, title string) (string
6060
}
6161
var found []string
6262
for _, item := range items {
63-
item := item
6463
if item == input {
6564
found = []string{item}
6665
break

format.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ func (t *taskFormatterJSON) AddTask(task types.Task) {
175175
func (t *taskFormatterJSON) Close() {
176176
}
177177

178-
func MarshalJSONForAPI(v interface{}, query *gojq.Query) ([]byte, error) {
178+
func MarshalJSONForAPI(v any, query *gojq.Query) ([]byte, error) {
179179
b, err := json.Marshal(v)
180180
if err != nil {
181181
return nil, err
182182
}
183-
m := map[string]interface{}{}
183+
m := map[string]any{}
184184
if err := json.Unmarshal(b, &m); err != nil {
185185
return nil, err
186186
}
@@ -206,8 +206,8 @@ func MarshalJSONForAPI(v interface{}, query *gojq.Query) ([]byte, error) {
206206
}
207207
}
208208

209-
func UnmarshalJSONForStruct(src []byte, v interface{}) error {
210-
m := map[string]interface{}{}
209+
func UnmarshalJSONForStruct(src []byte, v any) error {
210+
m := map[string]any{}
211211
if err := json.Unmarshal(src, &m); err != nil {
212212
return err
213213
}
@@ -233,26 +233,26 @@ func jsonKeyForStruct(s string) string {
233233
return strings.ToUpper(s[:1]) + s[1:]
234234
}
235235

236-
func walkMap(m map[string]interface{}, fn func(string) string) {
236+
func walkMap(m map[string]any, fn func(string) string) {
237237
for key, value := range m {
238238
delete(m, key)
239239
m[fn(key)] = value
240240
switch value := value.(type) {
241-
case map[string]interface{}:
241+
case map[string]any:
242242
walkMap(value, fn)
243-
case []interface{}:
243+
case []any:
244244
walkArray(value, fn)
245245
default:
246246
}
247247
}
248248
}
249249

250-
func walkArray(a []interface{}, fn func(string) string) {
250+
func walkArray(a []any, fn func(string) string) {
251251
for _, value := range a {
252252
switch value := value.(type) {
253-
case map[string]interface{}:
253+
case map[string]any:
254254
walkMap(value, fn)
255-
case []interface{}:
255+
case []any:
256256
walkArray(value, fn)
257257
default:
258258
}

portforward_integration_test.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ func TestTCPProxyToLocalhost(t *testing.T) {
2626
backendCtx, backendCancel := context.WithCancel(context.Background())
2727
defer backendCancel()
2828

29-
backendWg.Add(1)
30-
go func() {
31-
defer backendWg.Done()
29+
backendWg.Go(func() {
3230
for {
3331
select {
3432
case <-backendCtx.Done():
@@ -63,7 +61,7 @@ func TestTCPProxyToLocalhost(t *testing.T) {
6361
}
6462
}(conn)
6563
}
66-
}()
64+
})
6765

6866
// Get a different port for proxy frontend
6967
proxyListener, err := net.Listen("tcp", "0.0.0.0:0")
@@ -79,14 +77,12 @@ func TestTCPProxyToLocalhost(t *testing.T) {
7977
defer cancel()
8078

8179
var proxyWg sync.WaitGroup
82-
proxyWg.Add(1)
83-
go func() {
84-
defer proxyWg.Done()
80+
proxyWg.Go(func() {
8581
err := app.startTCPProxyToLocalhost(ctx, "0.0.0.0", proxyPort, backendPort)
8682
if err != nil && err != context.DeadlineExceeded && err != context.Canceled {
8783
t.Logf("Proxy ended with: %v", err)
8884
}
89-
}()
85+
})
9086

9187
// Wait a bit for proxy to start
9288
time.Sleep(50 * time.Millisecond)
@@ -192,11 +188,9 @@ func TestHandleProxyConnection(t *testing.T) {
192188

193189
// Start handleProxyConnection
194190
var proxyWg sync.WaitGroup
195-
proxyWg.Add(1)
196-
go func() {
197-
defer proxyWg.Done()
191+
proxyWg.Go(func() {
198192
app.handleProxyConnection(proxyCtx, serverConn, backendPort)
199-
}()
193+
})
200194

201195
// Test communication
202196
testData := "test data"

0 commit comments

Comments
 (0)