Skip to content

Conversation

@sreeram77
Copy link
Member

Description

  • fix: golangci-lint staticcheck errors

Testing & Reproduction steps

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@sreeram77 sreeram77 requested a review from a team as a code owner August 28, 2025 06:07
@sreeram77 sreeram77 requested a review from Copilot August 28, 2025 06:08
@github-actions github-actions bot added theme/acls ACL and token generation theme/cli Flags and documentation for the CLI interface theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies theme/internals Serf, Raft, SWIM, Lifeguard, Anti-Entropy, locking topics labels Aug 28, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes golangci-lint staticcheck errors across the codebase by replacing deprecated or inefficient Go constructs with their modern equivalents.

Key changes include:

  • Replacing deprecated fuzz.Continue.Rand methods with direct fuzz.Continue methods
  • Simplifying boolean comparisons and string operations
  • Improving loop constructs and variable assignments

Reviewed Changes

Copilot reviewed 73 out of 73 changed files in this pull request and generated no comments.

Show a summary per file
File Description
testrpc/wait.go Simplified field access by removing redundant QueryMeta wrapper
snapshot/snapshot_test.go Improved loop condition for leader check
proto/private/pbservice/convert_test.go Updated fuzz.Continue method calls to remove deprecated Rand field
lib/template/hil.go Replaced strings.Index with strings.Contains for better readability
lib/hoststats/cpu_test.go Replaced time.Now().Sub() with time.Since()
internal/resource/protoc-gen-json-shim/internal/generate/generate.go Simplified boolean comparison and replaced strings.Replace with strings.ReplaceAll
internal/resource/protoc-gen-deepcopy/internal/generate/generate.go Simplified boolean comparison
internal/resource/decode_test.go Fixed field access path by removing redundant Resource wrapper
internal/controller/controllertest/builder.go Simplified slice append operation
connect/certgen/certgen.go Removed redundant type specifications in variable declarations
command/version/formatter_test.go Removed unnecessary fmt.Sprintf wrapper
command/snapshot/inspect/formatter_test.go Removed unnecessary fmt.Sprintf wrapper
command/services/export/export.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/read/read.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/read-grpc/read.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/list/list.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/list-grpc/list.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/helper.go Improved switch statement efficiency and readability
command/resource/delete/delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/delete-grpc/delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/resource/client/client.go Simplified slice append and improved buffer string conversion
command/peering/list/list.go Removed unnecessary fmt.Sprintf wrapper for static string
command/peering/exportedservices/exported_services.go Simplified field access by removing redundant EnterpriseMeta wrapper
command/operator/autopilot/state/formatter.go Replaced string concatenation with fmt.Fprintf for better performance
command/logout/logout.go Removed unnecessary fmt.Sprintf wrapper for static string
command/login/login.go Removed unnecessary fmt.Sprintf wrapper for static string
command/lock/lock.go Removed unnecessary fmt.Sprintf wrapper for static string
command/kv/get/kv_get.go Simplified boolean logic and removed unnecessary fmt.Sprintf wrapper
command/keyring/keyring.go Replaced string concatenation with fmt.Fprintf for better performance
command/keygen/keygen.go Removed unnecessary fmt.Sprintf wrapper for static string
command/intention/match/match.go Removed unnecessary fmt.Sprintf wrapper for static string
command/intention/list/intention_list.go Removed unnecessary fmt.Sprintf wrapper for static string
command/intention/delete/delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/intention/check/check.go Removed unnecessary fmt.Sprintf wrapper for static string
command/flags/flag_slice_value_test.go Simplified variable declaration
command/exec/exec.go Removed unnecessary fmt.Sprintf wrapper for static string
command/connect/redirecttraffic/redirect_traffic.go Simplified multiple slice append operations
command/connect/proxy/proxy.go Removed unnecessary fmt.Sprintf wrapper for static string
command/connect/envoy/flags.go Replaced string concatenation with fmt.Fprintf for better performance
command/connect/envoy/envoy_test.go Replaced strings.Replace with strings.ReplaceAll
command/connect/envoy/envoy.go Replaced strings.Replace with strings.ReplaceAll
command/config/config.go Simplified boolean comparison
command/cli/cli.go Simplified field access by removing redundant BasicUi wrapper
command/catalog/list/nodes/catalog_list_nodes.go Simplified variable declaration
command/acl/token/read/token_read_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/token/formatter.go Simplified field access and replaced string concatenation with fmt.Fprintf
command/acl/token/delete/token_delete_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/templatedpolicy/preview/templated_policy_preview.go Improved comparison logic
command/acl/templatedpolicy/formatter.go Replaced string concatenation with fmt.Fprintf for better performance
command/acl/role/update/role_update.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/role/read/role_read_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/role/read/role_read.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/role/delete/role_delete_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/role/delete/role_delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/policy/update/policy_update.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/policy/read/policy_read_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/policy/read/policy_read.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/policy/delete/policy_delete_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/policy/delete/policy_delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/policy/create/policy_create.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/bindingrule/read/bindingrule_read_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/bindingrule/read/bindingrule_read.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/bindingrule/delete/bindingrule_delete_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/bindingrule/delete/bindingrule_delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/authmethod/update/authmethod_update.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/authmethod/read/authmethod_read.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/authmethod/delete/authmethod_delete_test.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/authmethod/delete/authmethod_delete.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/authmethod/create/authmethod_create.go Removed unnecessary fmt.Sprintf wrapper for static string
command/acl/agenttokens/agent_tokens.go Removed unnecessary fmt.Sprintf wrapper for static string
acl/policy_authorizer.go Simplified field access by removing redundant wrapper
acl/policy.go Simplified field access by removing redundant EnterpriseRule wrapper
acl/authorizer.go Simplified field access by removing redundant Authorizer wrapper

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sreeram77 sreeram77 added pr/no-changelog PR does not need a corresponding .changelog entry backport/all Apply backports for all active releases per .release/versions.hcl labels Aug 28, 2025
@sreeram77 sreeram77 enabled auto-merge (squash) August 28, 2025 06:43
@sreeram77 sreeram77 merged commit dbef0bf into main Aug 28, 2025
137 of 146 checks passed
@sreeram77 sreeram77 deleted the sreeram77/staticcheck-fix branch August 28, 2025 06:50
@hc-github-team-consul-core hc-github-team-consul-core added backport/1.21 This release series is longer active on CE, use backport/ent/1.21 backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 labels Aug 28, 2025
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.18,1.19,1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

4 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.18,1.19,1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.18,1.19,1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.18,1.19,1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.18,1.19,1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

4 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

29 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sreeram77! a backport is missing for this PR [22640] for versions [1.20] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/all Apply backports for all active releases per .release/versions.hcl backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 backport/1.21 This release series is longer active on CE, use backport/ent/1.21 pr/no-changelog PR does not need a corresponding .changelog entry theme/acls ACL and token generation theme/cli Flags and documentation for the CLI interface theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies theme/internals Serf, Raft, SWIM, Lifeguard, Anti-Entropy, locking topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants