Skip to content

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Aug 14, 2025

See individual commits for details. High level overview:

  • require go 1.24, add go 1.25 to CI, drop go 1.23
  • replace omitempty with omitzero everywhere (mostly this is a no-op and done for consistency, but for some fields, like nested struct fields, it will result in more "omitting" behavior)
  • add some golangci-extra exceptions for names (and moved some more from code to config)
  • modernize code for Go 1.24

Similar runc PR: opencontainers/runc#4851

@kolyshkin
Copy link
Contributor Author

lint-extra warnings should be ignored

@kolyshkin kolyshkin added this to the 0.1.0 milestone Aug 20, 2025
@kolyshkin kolyshkin marked this pull request as draft August 20, 2025 19:15
@kolyshkin
Copy link
Contributor Author

Draft until we release v0.0.5

@kolyshkin
Copy link
Contributor Author

Rebased.

@kolyshkin kolyshkin marked this pull request as ready for review September 5, 2025 21:09
ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
PSI *PSIStats `json:"psi,omitempty"`
BurstData BurstData `json:"burst_data,omitempty"`
CpuUsage CpuUsage `json:"cpu_usage,omitzero"`
Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is technical debt. We have two options:

  • Make a breaking change by renaming it to CPUUsage.
  • Add a //nolint:revive directive to suppress the warning.

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 third option is to ignore linters-extra warnings as they are technically for new code and this is not new code. In the next commit or PR linters-extra won't flag this issue as it won't be "new".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lifubang I've added the nolint directives as requested. Now the main linter errors out.

Alas our linter setup is not ideal -- the whole point of lint-extra job is to use more rules for new code only. When we change something, it is treated as "new code" while in fact it is not. This is why I said "let's ignore these warnings".

Also, this is not technical debt, as future patches won't hit this warning (lint-extra only checks "new" code).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm keeping the code as is for now, so you can take a look @lifubang

Copy link
Member

@cyphar cyphar Oct 30, 2025

Choose a reason for hiding this comment

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

I agree with keeping it as-is. The mess with lint-extra is unfortunate but such is the cost of working on "legacy" code. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Ended up naming exception to golangi-extra config (hoping we won't add new IDs with the whitelisted names).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...and moving existing exceptions to config file, too -- yay to less code clutter!

Bump go to 1.24 in go.mod. Remove go 1.23 and add go 1.25 to CI.

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin kolyshkin force-pushed the go124-min branch 2 times, most recently from e67ac1f to 324a463 Compare October 31, 2025 00:31
For some fields (like nested struct fields), omitempty has no effect
but omitzero does. Let's use it.

NOTE it might result in some compatibility issues since now
zero-only fields are not serialized.

Since linter-extra thinks it's a new code, add some naming exceptions.

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin kolyshkin force-pushed the go124-min branch 2 times, most recently from 9e042c0 to 0764414 Compare October 31, 2025 00:44
For some fields (like nested struct fields), omitempty has no effect
but omitzero does. Let's use it (everywhere -- for consistency).

NOTE it might result in some compatibility issues since now
zero-only fields are not serialized.

Since linter-extra thinks it's a new code, add some naming exceptions.

Signed-off-by: Kir Kolyshkin <[email protected]>
This is technically a no-op, but let's change it for consistency.

While at it, move linter-extra exceptions to golangci-extra.yml.

Signed-off-by: Kir Kolyshkin <[email protected]>
Mostly done by

	modernize -fix -test ./...

with some minor manual edits on top.

Signed-off-by: Kir Kolyshkin <[email protected]>
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