Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR applies modernization improvements to the codebase using the Go modernize tool. The changes leverage newer Go standard library features and language constructs to improve code clarity and maintainability.
- Replace manual loop-based searches with
slices.Contains()for cleaner array/slice membership checks - Use
maps.Copy()instead of manual map copying loops for better performance and readability - Modernize for-loop syntax using range-over-integer pattern available in Go 1.22+
- Replace
interface{}with the more modernanytype alias - Use
min()builtin function and other standard library improvements
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| security/scheme.go | Replaces manual slice search with slices.Contains() for scope validation |
| middleware/xray/segment.go | Consolidates function parameters, uses min() builtin, and modernizes for-loop syntax |
| middleware/sampler_test.go | Updates for-loops to use range-over-integer syntax |
| http/middleware/xray/segment_test.go | Uses http.NoBody and modernizes for-loop syntax |
| http/codegen/sse_client.go | Replaces interface{} with any type alias |
| http/codegen/sse.go | Replaces interface{} with any type alias |
| http/codegen/openapi/v3/types_test.go | Updates function parameter type from interface{} to any |
| http/codegen/openapi/v3/parameters.go | Replaces manual slice search with slices.Contains() |
| http/codegen/openapi/v3/builder.go | Uses maps.Copy() instead of manual map copying |
| http/codegen/openapi/v2/builder.go | Uses maps.Copy() and slices.Contains() for cleaner code |
| http/codegen/openapi/marshal.go | Replaces manual map copying with maps.Copy() |
| http/codegen/openapi/extensions.go | Uses maps.Copy() for map merging operations |
| http/client.go | Uses fmt.Appendf() instead of manual slice formatting |
| grpc/middleware/xray/segment_test.go | Modernizes for-loop syntax |
| expr/types.go | Updates for-loops to use range-over-integer syntax |
| expr/server.go | Replaces manual slice searches with slices.Contains() |
| expr/root.go | Uses maps.Copy() and slices.Contains() for cleaner code |
| expr/mapped_attribute.go | Uses maps.Copy() for map duplication |
| expr/http_endpoint_test.go | Modernizes for-loop syntax |
| expr/http_endpoint.go | Replaces multiple manual slice searches with slices.Contains() |
| expr/grpc_endpoint.go | Uses slices.Contains() for cleaner membership checks |
| expr/example.go | Uses min() builtin, modernizes for-loops, and renames shadowed variables |
| expr/attribute.go | Replaces manual slice searches with slices.Contains() |
| dsl/result_type.go | Uses built-in copy() function for slice copying |
| dsl/meta_test.go | Uses slices.Contains() in test helper function |
| codegen/service/service_data.go | Replaces manual slice search with slices.Contains() |
| codegen/service/interceptors.go | Replaces interface{} with any type alias |
| codegen/funcs.go | Consolidates function parameters and modernizes for-loop syntax |
| codegen/file.go | Uses maps.Copy() and updates file permissions to be more restrictive |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
This is great, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://pkg.go.dev/golang.org/x/tools/gopls@v0.20.0/internal/analysis/modernize