-
Notifications
You must be signed in to change notification settings - Fork 53
lint fixes #151
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
lint fixes #151
Conversation
f5aeae2
to
f2f526a
Compare
5a6f565
to
b5cb64d
Compare
modern go tooling requires a version with `go install`.
The constants in particular could have been used, but do not seem that they'd improve readability: these aren't "magic" byte literals, because they're well and widely understood aspects of the JSON syntax.
c6c371b
to
0e2637e
Compare
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 addresses several golangci-lint issues to improve code quality and maintainability. The changes focus on removing unused code, updating deprecated API usage, and following Go best practices.
- Removes unused constants and variables
- Updates deprecated
reflect.PtrTo
calls toreflect.PointerTo
- Improves error handling with
errors.Is()
and proper variable scoping
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
json/parse.go | Removes unused escape and quote constants |
json/json_test.go | Adds lint suppression comments and improves error handling |
json/json.go | Adds lint suppression comments for deprecated types |
json/decode.go | Updates deprecated reflect API and marks unused parameter |
json/codec.go | Updates deprecated reflect API and uses maps.Copy |
benchmarks/Makefile | Pins benchstat installation to latest version |
.golangci.yml | Adds linter configuration |
.github/workflows/benchmark.yml | Fixes typo in step name |
|
||
func cacheStore(typ reflect.Type, cod codec, oldCodecs map[unsafe.Pointer]codec) { | ||
newCodecs := make(map[unsafe.Pointer]codec, len(oldCodecs)+1) | ||
maps.Copy(newCodecs, oldCodecs) |
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.
Using maps.Copy is more efficient than manually iterating over the map entries
Copilot uses AI. Check for mistakes.
for { | ||
var o obj | ||
err = d.Decode(&o) | ||
err := d.Decode(&o) |
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.
Variable scoping improved by declaring err within the loop scope where it's used
Copilot uses AI. Check for mistakes.
err := d.Decode(&o) | ||
if err != nil { | ||
if err == io.EOF { | ||
if errors.Is(err, io.EOF) { |
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.
Using errors.Is() is the recommended way to check for specific errors instead of direct equality comparison
Copilot uses AI. Check for mistakes.
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Several (but not all) golangci-lint issues have been resolved.
Benchmark impact appears to be neutral.