-
-
Notifications
You must be signed in to change notification settings - Fork 574
Apply modernize #3750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply modernize #3750
Conversation
There was a problem hiding this 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 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 <[email protected]>
|
This is great, thank you! |
https://pkg.go.dev/golang.org/x/tools/[email protected]/internal/analysis/modernize