Skip to content

Commit bb5aa17

Browse files
committed
fix: resolve unused-parameter warnings for Go 1.24.1 compatibility
1 parent 59e1b9c commit bb5aa17

File tree

21 files changed

+34
-34
lines changed

21 files changed

+34
-34
lines changed

agent/agent.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ func (a *agent) HTTPDebug() http.Handler {
17341734
r.Get("/debug/magicsock", a.HandleHTTPDebugMagicsock)
17351735
r.Get("/debug/magicsock/debug-logging/{state}", a.HandleHTTPMagicsockDebugLoggingState)
17361736
r.Get("/debug/manifest", a.HandleHTTPDebugManifest)
1737-
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
1737+
r.NotFound(func(w http.ResponseWriter, _ *http.Request) {
17381738
w.WriteHeader(http.StatusNotFound)
17391739
_, _ = w.Write([]byte("404 not found"))
17401740
})
@@ -2020,7 +2020,7 @@ func (a *apiConnRoutineManager) wait() error {
20202020
}
20212021

20222022
func PrometheusMetricsHandler(prometheusRegistry *prometheus.Registry, logger slog.Logger) http.Handler {
2023-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2023+
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
20242024
w.Header().Set("Content-Type", "text/plain")
20252025

20262026
// Based on: https://github.com/tailscale/tailscale/blob/280255acae604796a1113861f5a84e6fa2dc6121/ipn/localapi/localapi.go#L489

agent/agentssh/agentssh.go

+2-2
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
return true
225225
},
226-
PtyCallback: func(ctx ssh.Context, pty ssh.Pty) bool {
226+
PtyCallback: func(_ ssh.Context, _ ssh.Pty) bool {
227227
return true
228228
},
229229
ReversePortForwardingCallback: func(ctx ssh.Context, bindHost string, bindPort uint32) 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
}

cli/exp_errors.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func (RootCmd) errorExample() *serpent.Command {
1616
errorCmd := func(use string, err error) *serpent.Command {
1717
return &serpent.Command{
1818
Use: use,
19-
Handler: func(inv *serpent.Invocation) error {
19+
Handler: func(_ *serpent.Invocation) error {
2020
return err
2121
},
2222
}
@@ -57,7 +57,7 @@ func (RootCmd) errorExample() *serpent.Command {
5757
Long: "This command is pretty pointless, but without it testing errors is" +
5858
"difficult to visually inspect. Error message formatting is inherently" +
5959
"visual, so we need a way to quickly see what they look like.",
60-
Handler: func(inv *serpent.Invocation) error {
60+
Handler: func(_ *serpent.Invocation) error {
6161
return inv.Command.HelpHandler(inv)
6262
},
6363
Children: []*serpent.Command{
@@ -70,7 +70,7 @@ func (RootCmd) errorExample() *serpent.Command {
7070
// A multi-error
7171
{
7272
Use: "multi-error",
73-
Handler: func(inv *serpent.Invocation) error {
73+
Handler: func(_ *serpent.Invocation) error {
7474
return xerrors.Errorf("wrapped: %w", errors.Join(
7575
xerrors.Errorf("first error: %w", errorWithStackTrace()),
7676
xerrors.Errorf("second error: %w", errorWithStackTrace()),
@@ -81,7 +81,7 @@ func (RootCmd) errorExample() *serpent.Command {
8181
{
8282
Use: "multi-multi-error",
8383
Short: "This is a multi error inside a multi error",
84-
Handler: func(inv *serpent.Invocation) error {
84+
Handler: func(_ *serpent.Invocation) error {
8585
return errors.Join(
8686
xerrors.Errorf("parent error: %w", errorWithStackTrace()),
8787
errors.Join(
@@ -100,7 +100,7 @@ func (RootCmd) errorExample() *serpent.Command {
100100
Required: true,
101101
Flag: "magic-word",
102102
Default: "",
103-
Value: serpent.Validate(&magicWord, func(value *serpent.String) error {
103+
Value: serpent.Validate(&magicWord, func(_ *serpent.String) error {
104104
return xerrors.Errorf("magic word is incorrect")
105105
}),
106106
},

cli/open.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (r *RootCmd) openVSCode() *serpent.Command {
9999
// However, if no directory is set, the expanded directory will
100100
// not be set either.
101101
if workspaceAgent.Directory != "" {
102-
workspace, workspaceAgent, err = waitForAgentCond(ctx, client, workspace, workspaceAgent, func(a codersdk.WorkspaceAgent) bool {
102+
workspace, workspaceAgent, err = waitForAgentCond(ctx, client, workspace, workspaceAgent, func(_ codersdk.WorkspaceAgent) bool {
103103
return workspaceAgent.LifecycleState != codersdk.WorkspaceAgentLifecycleCreated
104104
})
105105
if err != nil {

coderd/coderd.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ func New(options *Options) *API {
829829
// we do not override subdomain app routes.
830830
r.Get("/latency-check", tracing.StatusWriterMiddleware(prometheusMW(LatencyCheck())).ServeHTTP)
831831

832-
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("OK")) })
832+
r.Get("/healthz", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("OK")) })
833833

834834
// Attach workspace apps routes.
835835
r.Group(func(r chi.Router) {
@@ -844,7 +844,7 @@ func New(options *Options) *API {
844844
r.Route("/derp", func(r chi.Router) {
845845
r.Get("/", derpHandler.ServeHTTP)
846846
// This is used when UDP is blocked, and latency must be checked via HTTP(s).
847-
r.Get("/latency-check", func(w http.ResponseWriter, r *http.Request) {
847+
r.Get("/latency-check", func(w http.ResponseWriter, _ *http.Request) {
848848
w.WriteHeader(http.StatusOK)
849849
})
850850
})
@@ -901,7 +901,7 @@ func New(options *Options) *API {
901901
r.Route("/api/v2", func(r chi.Router) {
902902
api.APIHandler = r
903903

904-
r.NotFound(func(rw http.ResponseWriter, r *http.Request) { httpapi.RouteNotFound(rw) })
904+
r.NotFound(func(rw http.ResponseWriter, _ *http.Request) { httpapi.RouteNotFound(rw) })
905905
r.Use(
906906
// Specific routes can specify different limits, but every rate
907907
// limit must be configurable by the admin.

coderd/coderdtest/coderdtest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ func MustWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID)
11941194
// RequestExternalAuthCallback makes a request with the proper OAuth2 state cookie
11951195
// to the external auth callback endpoint.
11961196
func RequestExternalAuthCallback(t testing.TB, providerID string, client *codersdk.Client, opts ...func(*http.Request)) *http.Response {
1197-
client.HTTPClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
1197+
client.HTTPClient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
11981198
return http.ErrUseLastResponse
11991199
}
12001200
state := "somestate"

coderd/coderdtest/oidctest/idp.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ func NewFakeIDP(t testing.TB, opts ...FakeIDPOpt) *FakeIDP {
339339
refreshIDTokenClaims: syncmap.New[string, jwt.MapClaims](),
340340
deviceCode: syncmap.New[string, deviceFlow](),
341341
hookOnRefresh: func(_ string) error { return nil },
342-
hookUserInfo: func(email string) (jwt.MapClaims, error) { return jwt.MapClaims{}, nil },
343-
hookValidRedirectURL: func(redirectURL string) error { return nil },
342+
hookUserInfo: func(_ string) (jwt.MapClaims, error) { return jwt.MapClaims{}, nil },
343+
hookValidRedirectURL: func(_ string) error { return nil },
344344
defaultExpire: time.Minute * 5,
345345
}
346346

@@ -553,7 +553,7 @@ func (f *FakeIDP) ExternalLogin(t testing.TB, client *codersdk.Client, opts ...f
553553
f.SetRedirect(t, coderOauthURL.String())
554554

555555
cli := f.HTTPClient(client.HTTPClient)
556-
cli.CheckRedirect = func(req *http.Request, via []*http.Request) error {
556+
cli.CheckRedirect = func(req *http.Request, _ []*http.Request) error {
557557
// Store the idTokenClaims to the specific state request. This ties
558558
// the claims 1:1 with a given authentication flow.
559559
state := req.URL.Query().Get("state")
@@ -1210,7 +1210,7 @@ func (f *FakeIDP) httpHandler(t testing.TB) http.Handler {
12101210
}.Encode())
12111211
}))
12121212

1213-
mux.NotFound(func(rw http.ResponseWriter, r *http.Request) {
1213+
mux.NotFound(func(_ http.ResponseWriter, r *http.Request) {
12141214
f.logger.Error(r.Context(), "http call not found", slogRequestFields(r)...)
12151215
t.Errorf("unexpected request to IDP at path %q. Not supported", r.URL.Path)
12161216
})

coderd/coderdtest/swaggerparser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func VerifySwaggerDefinitions(t *testing.T, router chi.Router, swaggerComments [
151151
assertUniqueRoutes(t, swaggerComments)
152152
assertSingleAnnotations(t, swaggerComments)
153153

154-
err := chi.Walk(router, func(method, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
154+
err := chi.Walk(router, func(method, route string, _ http.Handler, _ ...func(http.Handler) http.Handler) error {
155155
method = strings.ToLower(method)
156156
if route != "/" && strings.HasSuffix(route, "/") {
157157
route = route[:len(route)-1]

coderd/database/dbauthz/dbauthz.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3364,7 +3364,7 @@ func (q *querier) InsertUserGroupsByName(ctx context.Context, arg database.Inser
33643364
// This will add the user to all named groups. This counts as updating a group.
33653365
// NOTE: instead of checking if the user has permission to update each group, we instead
33663366
// check if the user has permission to update *a* group in the org.
3367-
fetch := func(ctx context.Context, arg database.InsertUserGroupsByNameParams) (rbac.Objecter, error) {
3367+
fetch := func(_ context.Context, arg database.InsertUserGroupsByNameParams) (rbac.Objecter, error) {
33683368
return rbac.ResourceGroup.InOrg(arg.OrganizationID), nil
33693369
}
33703370
return update(q.log, q.auth, fetch, q.db.InsertUserGroupsByName)(ctx, arg)

coderd/httpmw/cors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func Cors(allowAll bool, origins ...string) func(next http.Handler) http.Handler
4646

4747
func WorkspaceAppCors(regex *regexp.Regexp, app appurl.ApplicationURL) func(next http.Handler) http.Handler {
4848
return cors.Handler(cors.Options{
49-
AllowOriginFunc: func(r *http.Request, rawOrigin string) bool {
49+
AllowOriginFunc: func(_ *http.Request, rawOrigin string) bool {
5050
origin, err := url.Parse(rawOrigin)
5151
if rawOrigin == "" || origin.Host == "" || err != nil {
5252
return false

coderd/tracing/exporter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TracerProvider(ctx context.Context, service string, opts TracerOpts) (*sdkt
9898
tracerProvider := sdktrace.NewTracerProvider(tracerOpts...)
9999
otel.SetTracerProvider(tracerProvider)
100100
// Ignore otel errors!
101-
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {}))
101+
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(_ error) {}))
102102
otel.SetTextMapPropagator(
103103
propagation.NewCompositeTextMapPropagator(
104104
propagation.TraceContext{},

coderd/updatecheck/updatecheck.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func New(db database.Store, log slog.Logger, opts Options) *Checker {
7373
opts.UpdateTimeout = 30 * time.Second
7474
}
7575
if opts.Notify == nil {
76-
opts.Notify = func(r Result) {}
76+
opts.Notify = func(_ Result) {}
7777
}
7878

7979
ctx, cancel := context.WithCancel(context.Background())

coderd/workspaceapps/apptest/setup.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (d *Details) AppClient(t *testing.T) *codersdk.Client {
127127
client := codersdk.New(d.PathAppBaseURL)
128128
client.SetSessionToken(d.SDKClient.SessionToken())
129129
forceURLTransport(t, client)
130-
client.HTTPClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
130+
client.HTTPClient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
131131
return http.ErrUseLastResponse
132132
}
133133

@@ -182,7 +182,7 @@ func setupProxyTestWithFactory(t *testing.T, factory DeploymentFactory, opts *De
182182

183183
// Configure the HTTP client to not follow redirects and to route all
184184
// requests regardless of hostname to the coderd test server.
185-
deployment.SDKClient.HTTPClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
185+
deployment.SDKClient.HTTPClient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
186186
return http.ErrUseLastResponse
187187
}
188188
forceURLTransport(t, deployment.SDKClient)

enterprise/audit/filter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Filter interface {
2929

3030
// DefaultFilter is the default filter used when exporting audit logs. It allows
3131
// storage and exporting for all audit logs.
32-
var DefaultFilter Filter = FilterFunc(func(_ context.Context, alog database.AuditLog) (FilterDecision, error) {
32+
var DefaultFilter Filter = FilterFunc(func(_ context.Context, _ database.AuditLog) (FilterDecision, error) {
3333
// Store and export all audit logs for now.
3434
return FilterDecisionStore | FilterDecisionExport, nil
3535
})

enterprise/replicasync/replicasync.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (m *Manager) subscribe(ctx context.Context) error {
203203
updating = false
204204
updateMutex.Unlock()
205205
}
206-
cancelFunc, err := m.pubsub.Subscribe(PubsubEvent, func(ctx context.Context, message []byte) {
206+
cancelFunc, err := m.pubsub.Subscribe(PubsubEvent, func(_ context.Context, message []byte) {
207207
updateMutex.Lock()
208208
defer updateMutex.Unlock()
209209
id, err := uuid.Parse(string(message))

enterprise/wsproxy/wsproxysdk/wsproxysdk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func New(serverURL *url.URL) *Client {
3838
sdkClient.SessionTokenHeader = httpmw.WorkspaceProxyAuthTokenHeader
3939

4040
sdkClientIgnoreRedirects := codersdk.New(serverURL)
41-
sdkClientIgnoreRedirects.HTTPClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
41+
sdkClientIgnoreRedirects.HTTPClient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
4242
return http.ErrUseLastResponse
4343
}
4444
sdkClientIgnoreRedirects.SessionTokenHeader = httpmw.WorkspaceProxyAuthTokenHeader

provisioner/terraform/cleanup.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func CleanStaleTerraformPlugins(ctx context.Context, cachePath string, fs afero.
130130
// the last created/modified file.
131131
func latestModTime(fs afero.Fs, pluginPath string) (time.Time, error) {
132132
var latest time.Time
133-
err := afero.Walk(fs, pluginPath, func(path string, info os.FileInfo, err error) error {
133+
err := afero.Walk(fs, pluginPath, func(_ string, info os.FileInfo, err error) error {
134134
if err != nil {
135135
return err
136136
}

scaletest/agentconn/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func agentHTTPClient(conn *workspacesdk.AgentConn) *http.Client {
368368
return &http.Client{
369369
Transport: &http.Transport{
370370
DisableKeepAlives: true,
371-
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
371+
DialContext: func(ctx context.Context, _ string, addr string) (net.Conn, error) {
372372
_, port, err := net.SplitHostPort(addr)
373373
if err != nil {
374374
return nil, xerrors.Errorf("split host port %q: %w", addr, err)

scaletest/dashboard/chromedp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func clickRandomElement(ctx context.Context, log slog.Logger, randIntn func(int)
119119
return "", nil, xerrors.Errorf("no matches found")
120120
}
121121
match := pick(matches, randIntn)
122-
act := func(actx context.Context) error {
122+
act := func(_ context.Context) error {
123123
log.Debug(ctx, "clicking", slog.F("label", match.Label), slog.F("xpath", match.ClickOn))
124124
if err := runWithDeadline(ctx, deadline, chromedp.Click(match.ClickOn, chromedp.NodeReady)); err != nil {
125125
log.Error(ctx, "click failed", slog.F("label", match.Label), slog.F("xpath", match.ClickOn), slog.Error(err))

scripts/dbgen/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func run() error {
5353
}
5454
databasePath := filepath.Join(localPath, "..", "..", "..", "coderd", "database")
5555

56-
err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbmem", "dbmem.go"), "q", "FakeQuerier", func(params stubParams) string {
56+
err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbmem", "dbmem.go"), "q", "FakeQuerier", func(_ stubParams) string {
5757
return `panic("not implemented")`
5858
})
5959
if err != nil {
@@ -72,7 +72,7 @@ return %s
7272
return xerrors.Errorf("stub dbmetrics: %w", err)
7373
}
7474

75-
err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbauthz", "dbauthz.go"), "q", "querier", func(params stubParams) string {
75+
err = orderAndStubDatabaseFunctions(filepath.Join(databasePath, "dbauthz", "dbauthz.go"), "q", "querier", func(_ stubParams) string {
7676
return `panic("not implemented")`
7777
})
7878
if err != nil {

tailnet/service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func NewNetworkTelemetryBatcher(clk quartz.Clock, frequency time.Duration, maxSi
322322
done: make(chan struct{}),
323323
}
324324
if b.batchFn == nil {
325-
b.batchFn = func(batch []*proto.TelemetryEvent) {}
325+
b.batchFn = func(_ []*proto.TelemetryEvent) {}
326326
}
327327
b.start()
328328
return b

0 commit comments

Comments
 (0)