Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit338439c

Browse files
sreyaClaude
and
Claude
authored
chore: update go to 1.24.1 (#17194)
Co-authored-by: Claude <claude@anthropic.com>
1 parent427e7fe commit338439c

File tree

187 files changed

+652
-545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+652
-545
lines changed

‎.github/actions/setup-go/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description:"The Go version to use."
7-
default:"1.22.12"
7+
default:"1.24.1"
88
runs:
99
using:"composite"
1010
steps:

‎.golangci.yaml

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,19 @@ linters-settings:
2424
enabled-checks:
2525
# - appendAssign
2626
# - appendCombine
27-
-argOrder
2827
# - assignOp
2928
# - badCall
30-
-badCond
3129
-badLock
3230
-badRegexp
3331
-boolExprSimplify
3432
# - builtinShadow
3533
-builtinShadowDecl
36-
-captLocal
37-
-caseOrder
38-
-codegenComment
3934
# - commentedOutCode
4035
-commentedOutImport
41-
-commentFormatting
42-
-defaultCaseOrder
4336
-deferUnlambda
4437
# - deprecatedComment
4538
# - docStub
46-
-dupArg
47-
-dupBranchBody
48-
-dupCase
4939
-dupImport
50-
-dupSubExpr
5140
# - elseif
5241
-emptyFallthrough
5342
# - emptyStringTest
@@ -56,56 +45,43 @@ linters-settings:
5645
# - exitAfterDefer
5746
# - exposedSyncMutex
5847
# - filepathJoin
59-
-flagDeref
60-
-flagName
6148
-hexLiteral
6249
# - httpNoBody
6350
# - hugeParam
6451
# - ifElseChain
6552
# - importShadow
6653
-indexAlloc
6754
-initClause
68-
-mapKey
6955
-methodExprCall
7056
# - nestingReduce
71-
-newDeref
7257
-nilValReturn
7358
# - octalLiteral
74-
-offBy1
7559
# - paramTypeCombine
7660
# - preferStringWriter
7761
# - preferWriteByte
7862
# - ptrToRefParam
7963
# - rangeExprCopy
8064
# - rangeValCopy
81-
-regexpMust
8265
-regexpPattern
8366
# - regexpSimplify
8467
-ruleguard
85-
-singleCaseSwitch
86-
-sloppyLen
8768
# - sloppyReassign
88-
-sloppyTypeAssert
8969
-sortSlice
9070
-sprintfQuotedString
9171
-sqlQuery
9272
# - stringConcatSimplify
9373
# - stringXbytes
9474
# - suspiciousSorting
95-
-switchTrue
9675
-truncateCmp
9776
-typeAssertChain
9877
# - typeDefFirst
99-
-typeSwitchVar
10078
# - typeUnparen
101-
-underef
10279
# - unlabelStmt
10380
# - unlambda
10481
# - unnamedResult
10582
# - unnecessaryBlock
10683
# - unnecessaryDefer
10784
# - unslice
108-
-valSwap
10985
-weakCond
11086
# - whyNoLint
11187
# - wrapperFunc
@@ -203,6 +179,14 @@ linters-settings:
203179
-G601
204180

205181
issues:
182+
exclude-dirs:
183+
-coderd/database/dbmem
184+
-node_modules
185+
-.git
186+
187+
exclude-files:
188+
-scripts/rules.go
189+
206190
# Rules listed here: https://github.com/securego/gosec#available-rules
207191
exclude-rules:
208192
-path:_test\.go
@@ -211,20 +195,20 @@ issues:
211195
-errcheck
212196
-forcetypeassert
213197
-exhaustruct# This is unhelpful in tests.
198+
-revive# TODO(JonA): disabling in order to update golangci-lint
199+
-gosec# TODO(JonA): disabling in order to update golangci-lint
214200
-path:scripts/*
215201
linters:
216202
-exhaustruct
203+
-path:scripts/rules.go
204+
linters:
205+
-ALL
217206

218207
fix:true
219208
max-issues-per-linter:0
220209
max-same-issues:0
221210

222211
run:
223-
skip-dirs:
224-
-node_modules
225-
-.git
226-
skip-files:
227-
-scripts/rules.go
228212
timeout:10m
229213

230214
# Over time, add more and more linters from

‎agent/agent.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ func (a *agent) run() (retErr error) {
936936
connMan.startAgentAPI("send logs",gracefulShutdownBehaviorRemain,
937937
func(ctx context.Context,aAPI proto.DRPCAgentClient24)error {
938938
err:=a.logSender.SendLoop(ctx,aAPI)
939-
ifxerrors.Is(err,agentsdk.LogLimitExceededError) {
939+
ifxerrors.Is(err,agentsdk.ErrLogLimitExceeded) {
940940
// we don't want this error to tear down the API connection and propagate to the
941941
// other routines that use the API. The LogSender has already dropped a warning
942942
// log, so just return nil here.
@@ -1583,9 +1583,13 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15831583
}
15841584
forconn,counts:=rangenetworkStats {
15851585
stats.ConnectionsByProto[conn.Proto.String()]++
1586+
// #nosec G115 - Safe conversions for network statistics which we expect to be within int64 range
15861587
stats.RxBytes+=int64(counts.RxBytes)
1588+
// #nosec G115 - Safe conversions for network statistics which we expect to be within int64 range
15871589
stats.RxPackets+=int64(counts.RxPackets)
1590+
// #nosec G115 - Safe conversions for network statistics which we expect to be within int64 range
15881591
stats.TxBytes+=int64(counts.TxBytes)
1592+
// #nosec G115 - Safe conversions for network statistics which we expect to be within int64 range
15891593
stats.TxPackets+=int64(counts.TxPackets)
15901594
}
15911595

@@ -1638,11 +1642,12 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
16381642
wg.Wait()
16391643
sort.Float64s(durations)
16401644
durationsLength:=len(durations)
1641-
ifdurationsLength==0 {
1645+
switch {
1646+
casedurationsLength==0:
16421647
stats.ConnectionMedianLatencyMs=-1
1643-
}elseifdurationsLength%2==0 {
1648+
casedurationsLength%2==0:
16441649
stats.ConnectionMedianLatencyMs= (durations[durationsLength/2-1]+durations[durationsLength/2])/2
1645-
}else {
1650+
default:
16461651
stats.ConnectionMedianLatencyMs=durations[durationsLength/2]
16471652
}
16481653
// Convert from microseconds to milliseconds.
@@ -1749,7 +1754,7 @@ func (a *agent) HTTPDebug() http.Handler {
17491754
r.Get("/debug/magicsock",a.HandleHTTPDebugMagicsock)
17501755
r.Get("/debug/magicsock/debug-logging/{state}",a.HandleHTTPMagicsockDebugLoggingState)
17511756
r.Get("/debug/manifest",a.HandleHTTPDebugManifest)
1752-
r.NotFound(func(w http.ResponseWriter,r*http.Request) {
1757+
r.NotFound(func(w http.ResponseWriter,_*http.Request) {
17531758
w.WriteHeader(http.StatusNotFound)
17541759
_,_=w.Write([]byte("404 not found"))
17551760
})
@@ -2034,7 +2039,7 @@ func (a *apiConnRoutineManager) wait() error {
20342039
}
20352040

20362041
funcPrometheusMetricsHandler(prometheusRegistry*prometheus.Registry,logger slog.Logger) http.Handler {
2037-
returnhttp.HandlerFunc(func(w http.ResponseWriter,r*http.Request) {
2042+
returnhttp.HandlerFunc(func(w http.ResponseWriter,_*http.Request) {
20382043
w.Header().Set("Content-Type","text/plain")
20392044

20402045
// Based on: https://github.com/tailscale/tailscale/blob/280255acae604796a1113861f5a84e6fa2dc6121/ipn/localapi/localapi.go#L489
@@ -2070,5 +2075,6 @@ func WorkspaceKeySeed(workspaceID uuid.UUID, agentName string) (int64, error) {
20702075
return42,err
20712076
}
20722077

2078+
// #nosec G115 - Safe conversion to generate int64 hash from Sum64, data loss acceptable
20732079
returnint64(h.Sum64()),nil
20742080
}

‎agent/agentcontainers/containers_dockercli.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,9 @@ func convertDockerInspect(raw []byte) ([]codersdk.WorkspaceAgentContainer, []str
453453
hostPortContainers[hp]=append(hostPortContainers[hp],in.ID)
454454
}
455455
out.Ports=append(out.Ports, codersdk.WorkspaceAgentContainerPort{
456-
Network:network,
457-
Port:cp,
456+
Network:network,
457+
Port:cp,
458+
// #nosec G115 - Safe conversion since Docker ports are limited to uint16 range
458459
HostPort:uint16(hp),
459460
HostIP:p.HostIP,
460461
})
@@ -497,12 +498,14 @@ func convertDockerPort(in string) (uint16, string, error) {
497498
iferr!=nil {
498499
return0,"",xerrors.Errorf("invalid port format: %s",in)
499500
}
501+
// #nosec G115 - Safe conversion since Docker TCP ports are limited to uint16 range
500502
returnuint16(p),"tcp",nil
501503
case2:
502504
p,err:=strconv.Atoi(parts[0])
503505
iferr!=nil {
504506
return0,"",xerrors.Errorf("invalid port format: %s",in)
505507
}
508+
// #nosec G115 - Safe conversion since Docker ports are limited to uint16 range
506509
returnuint16(p),parts[1],nil
507510
default:
508511
return0,"",xerrors.Errorf("invalid port format: %s",in)

‎agent/agentrsa/key_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func BenchmarkGenerateDeterministicKey(b *testing.B) {
2828
forrangeb.N {
2929
// always record the result of DeterministicPrivateKey to prevent
3030
// the compiler eliminating the function call.
31+
// #nosec G404 - Using math/rand is acceptable for benchmarking deterministic keys
3132
r=agentrsa.GenerateDeterministicKey(rand.Int64())
3233
}
3334

‎agent/agentssh/agentssh.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
223223
slog.F("destination_port",destinationPort))
224224
returntrue
225225
},
226-
PtyCallback:func(ctx ssh.Context,pty ssh.Pty)bool {
226+
PtyCallback:func(_ ssh.Context,_ ssh.Pty)bool {
227227
returntrue
228228
},
229229
ReversePortForwardingCallback:func(ctx ssh.Context,bindHoststring,bindPortuint32)bool {
@@ -240,7 +240,7 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
240240
"cancel-streamlocal-forward@openssh.com":unixForwardHandler.HandleSSHRequest,
241241
},
242242
X11Callback:s.x11Callback,
243-
ServerConfigCallback:func(ctx ssh.Context)*gossh.ServerConfig {
243+
ServerConfigCallback:func(_ ssh.Context)*gossh.ServerConfig {
244244
return&gossh.ServerConfig{
245245
NoClientAuth:true,
246246
}
@@ -702,6 +702,7 @@ func (s *Server) startPTYSession(logger slog.Logger, session ptySession, magicTy
702702
windowSize=nil
703703
continue
704704
}
705+
// #nosec G115 - Safe conversions for terminal dimensions which are expected to be within uint16 range
705706
resizeErr:=ptty.Resize(uint16(win.Height),uint16(win.Width))
706707
// If the pty is closed, then command has exited, no need to log.
707708
ifresizeErr!=nil&&!errors.Is(resizeErr,pty.ErrClosed) {

‎agent/agentssh/x11.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ func (s *Server) x11Handler(ctx ssh.Context, x11 ssh.X11) (displayNumber int, ha
116116
OriginatorPortuint32
117117
}{
118118
OriginatorAddress:tcpAddr.IP.String(),
119-
OriginatorPort:uint32(tcpAddr.Port),
119+
// #nosec G115 - Safe conversion as TCP port numbers are within uint32 range (0-65535)
120+
OriginatorPort:uint32(tcpAddr.Port),
120121
}))
121122
iferr!=nil {
122123
s.logger.Warn(ctx,"failed to open X11 channel",slog.Error(err))
@@ -294,6 +295,7 @@ func addXauthEntry(ctx context.Context, fs afero.Fs, host string, display string
294295
returnxerrors.Errorf("failed to write family: %w",err)
295296
}
296297

298+
// #nosec G115 - Safe conversion for host name length which is expected to be within uint16 range
297299
err=binary.Write(file,binary.BigEndian,uint16(len(host)))
298300
iferr!=nil {
299301
returnxerrors.Errorf("failed to write host length: %w",err)
@@ -303,6 +305,7 @@ func addXauthEntry(ctx context.Context, fs afero.Fs, host string, display string
303305
returnxerrors.Errorf("failed to write host: %w",err)
304306
}
305307

308+
// #nosec G115 - Safe conversion for display name length which is expected to be within uint16 range
306309
err=binary.Write(file,binary.BigEndian,uint16(len(display)))
307310
iferr!=nil {
308311
returnxerrors.Errorf("failed to write display length: %w",err)
@@ -312,6 +315,7 @@ func addXauthEntry(ctx context.Context, fs afero.Fs, host string, display string
312315
returnxerrors.Errorf("failed to write display: %w",err)
313316
}
314317

318+
// #nosec G115 - Safe conversion for auth protocol length which is expected to be within uint16 range
315319
err=binary.Write(file,binary.BigEndian,uint16(len(authProtocol)))
316320
iferr!=nil {
317321
returnxerrors.Errorf("failed to write auth protocol length: %w",err)
@@ -321,6 +325,7 @@ func addXauthEntry(ctx context.Context, fs afero.Fs, host string, display string
321325
returnxerrors.Errorf("failed to write auth protocol: %w",err)
322326
}
323327

328+
// #nosec G115 - Safe conversion for auth cookie length which is expected to be within uint16 range
324329
err=binary.Write(file,binary.BigEndian,uint16(len(authCookieBytes)))
325330
iferr!=nil {
326331
returnxerrors.Errorf("failed to write auth cookie length: %w",err)

‎agent/apphealth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func shouldStartTicker(app codersdk.WorkspaceApp) bool {
167167
returnapp.Healthcheck.URL!=""&&app.Healthcheck.Interval>0&&app.Healthcheck.Threshold>0
168168
}
169169

170-
funchealthChanged(oldmap[uuid.UUID]codersdk.WorkspaceAppHealth,newmap[uuid.UUID]codersdk.WorkspaceAppHealth)bool {
171-
forname,newValue:=rangenew {
170+
funchealthChanged(oldmap[uuid.UUID]codersdk.WorkspaceAppHealth,updatedmap[uuid.UUID]codersdk.WorkspaceAppHealth)bool {
171+
forname,newValue:=rangeupdated {
172172
oldValue,found:=old[name]
173173
if!found {
174174
returntrue

‎agent/metrics.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,22 @@ func (a *agent) collectMetrics(ctx context.Context) []*proto.Stats_Metric {
8989
for_,metric:=rangemetricFamily.GetMetric() {
9090
labels:=toAgentMetricLabels(metric.Label)
9191

92-
ifmetric.Counter!=nil {
92+
switch {
93+
casemetric.Counter!=nil:
9394
collected=append(collected,&proto.Stats_Metric{
9495
Name:metricFamily.GetName(),
9596
Type:proto.Stats_Metric_COUNTER,
9697
Value:metric.Counter.GetValue(),
9798
Labels:labels,
9899
})
99-
}elseifmetric.Gauge!=nil {
100+
casemetric.Gauge!=nil:
100101
collected=append(collected,&proto.Stats_Metric{
101102
Name:metricFamily.GetName(),
102103
Type:proto.Stats_Metric_GAUGE,
103104
Value:metric.Gauge.GetValue(),
104105
Labels:labels,
105106
})
106-
}else {
107+
default:
107108
a.logger.Error(ctx,"unsupported metric type",slog.F("type",metricFamily.Type.String()))
108109
}
109110
}

‎agent/reconnectingpty/buffered.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func newBuffered(ctx context.Context, logger slog.Logger, execer agentexec.Exece
6060
// Add TERM then start the command with a pty. pty.Cmd duplicates Path as the
6161
// first argument so remove it.
6262
cmdWithEnv:=execer.PTYCommandContext(ctx,cmd.Path,cmd.Args[1:]...)
63+
//nolint:gocritic
6364
cmdWithEnv.Env=append(rpty.command.Env,"TERM=xterm-256color")
6465
cmdWithEnv.Dir=rpty.command.Dir
6566
ptty,process,err:=pty.Start(cmdWithEnv)
@@ -236,7 +237,7 @@ func (rpty *bufferedReconnectingPTY) Wait() {
236237
_,_=rpty.state.waitForState(StateClosing)
237238
}
238239

239-
func (rpty*bufferedReconnectingPTY)Close(errorerror) {
240+
func (rpty*bufferedReconnectingPTY)Close(errerror) {
240241
// The closing state change will be handled by the lifecycle.
241-
rpty.state.setState(StateClosing,error)
242+
rpty.state.setState(StateClosing,err)
242243
}

‎agent/reconnectingpty/screen.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ func (rpty *screenReconnectingPTY) doAttach(ctx context.Context, conn net.Conn,
225225
rpty.command.Path,
226226
// pty.Cmd duplicates Path as the first argument so remove it.
227227
},rpty.command.Args[1:]...)...)
228+
//nolint:gocritic
228229
cmd.Env=append(rpty.command.Env,"TERM=xterm-256color")
229230
cmd.Dir=rpty.command.Dir
230231
ptty,process,err:=pty.Start(cmd,pty.WithPTYOption(
@@ -340,6 +341,7 @@ func (rpty *screenReconnectingPTY) sendCommand(ctx context.Context, command stri
340341
// -X runs a command in the matching session.
341342
"-X",command,
342343
)
344+
//nolint:gocritic
343345
cmd.Env=append(rpty.command.Env,"TERM=xterm-256color")
344346
cmd.Dir=rpty.command.Dir
345347
cmd.Stdout=&stdout

‎apiversion/apiversion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
// New returns an *APIVersion with the given major.minor and
1212
// additional supported major versions.
13-
funcNew(maj,minint)*APIVersion {
13+
funcNew(maj,minorint)*APIVersion {
1414
v:=&APIVersion{
1515
supportedMajor:maj,
16-
supportedMinor:min,
16+
supportedMinor:minor,
1717
additionalMajors:make([]int,0),
1818
}
1919
returnv

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp