Skip to content

Conversation

@jorbaum
Copy link
Contributor

@jorbaum jorbaum commented Sep 19, 2025

Description

Move to golangci-lint v2.

Issues were:

  • ST1001: Do not use dot imports for sources under cmd.
  • ST1005: to have nicer logs
  • QF1011: Remove redundant type int
  • QF1012: Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))

Noteworthy changes in golangci-lint v2:

  • New config format (migrated with migrate command)
  • Default timeout is now 0 instead of 1 minute. See here for rationale. Kept ours unchanged for now.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing performed?

  • Unit tests
  • Integration tests
  • Acceptance tests

Checklist:

  • This PR is being made against the main branch, or relevant version branch
  • I have made corresponding changes to the documentation
  • I have added testing for my changes

If you have any questions, or want to get attention for a PR or issue please reach out on the #logging-and-metrics channel in the cloudfoundry slack

Copy link
Contributor

@chombium chombium left a comment

Choose a reason for hiding this comment

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

@jorbaum Thanks for your PR

Please take a look at the small things to be fixed.

client "code.cloudfoundry.org/go-log-cache/v3"
"code.cloudfoundry.org/log-cache/internal/auth"
. "code.cloudfoundry.org/log-cache/internal/cfauthproxy"
cfProxy "code.cloudfoundry.org/log-cache/internal/cfauthproxy"
Copy link
Contributor

Choose a reason for hiding this comment

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

If the linter complains about the dot import, simply remove the dot at use the package name, cfauthproxy in this case, instead before each call.

FYI. The package alias should be all lowercase and without underscores. You can find more info on package naming conventions here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct. Just to explain myself: I did it this way to avoid naming collisions with gateway, nozzle and cache vars and to avoid changing this local var name.

I now abbreviated the local vars instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linked blog post was unepectedly a nice read. Most of its recommendations not only make sense for Go development ;) .

"strings"
"time"

// . imports are common usage of ginkgo
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use . "github.com/onsi/gomega" //nolint:staticcheck without the extra // . imports are common usage of ginkgo comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it.

Just to explain why I did it like that previously: My idea was that having a reason documented when ignoring rules makes it easier for others to understand why this decision was taken.

Noteworthy changes in golangci-lint v2:

* New config format (migrated with `migrate` command)
* Default timeout is now 0 instead of 1 minute.

Also fixes issues reported by golangci-lint v2:

* Do not use dot imports for sources under `cmd`.
* Have nicer logs
* Remove redundant type `int`
* Use `fmt.Fprintf(x, ...)` instead of `x.Write(fmt.Sprintf(...))`
Copy link
Contributor

@chombium chombium left a comment

Choose a reason for hiding this comment

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

you did to much now :)

Copy link
Contributor

@chombium chombium left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Application Runtime Platform Working Group Sep 19, 2025
@chombium chombium merged commit 97af51d into cloudfoundry:main Sep 19, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Application Runtime Platform Working Group Sep 19, 2025
@jorbaum jorbaum deleted the golangciv2 branch September 22, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants