Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

extemporalgenome
Copy link
Contributor

@extemporalgenome extemporalgenome commented Jul 28, 2025

Several (but not all) golangci-lint issues have been resolved.

Benchmark impact appears to be neutral.

@extemporalgenome extemporalgenome force-pushed the kgillette/2025-07/lint-fixes branch 2 times, most recently from f5aeae2 to f2f526a Compare July 28, 2025 18:43
@extemporalgenome extemporalgenome force-pushed the kgillette/2025-07/lint-fixes branch from 5a6f565 to b5cb64d Compare July 28, 2025 18:57
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.
@extemporalgenome extemporalgenome force-pushed the kgillette/2025-07/lint-fixes branch from c6c371b to 0e2637e Compare July 28, 2025 19:43
@greg-savage greg-savage requested review from Copilot July 28, 2025 20:32
Copy link

@Copilot 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 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 to reflect.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)
Copy link
Preview

Copilot AI Jul 28, 2025

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)
Copy link
Preview

Copilot AI Jul 28, 2025

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) {
Copy link
Preview

Copilot AI Jul 28, 2025

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.

Copy link

@Copilot 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

@Copilot 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@extemporalgenome extemporalgenome merged commit fd40685 into master Jul 29, 2025
11 checks passed
@extemporalgenome extemporalgenome deleted the kgillette/2025-07/lint-fixes branch July 29, 2025 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants