-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Modernize sources #26830
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
base: main
Are you sure you want to change the base?
Modernize sources #26830
Conversation
The code which comment refers to was removed by commit 2e4e1bb ("podman machine ssh handling"), so the comment is no longer valid. Remove it. Signed-off-by: Kir Kolyshkin <[email protected]>
Since Go 1.18, any is a type alias for interface{}. Brought to you by modernize -test -fix -category=efaceany ./... Signed-off-by: Kir Kolyshkin <[email protected]>
Replace a 3-clause for i := 0; i < n; i++ loop by for i := range n added in go1.22. Brought to you by modernize -test -fix -category=rangeint ./... (with some manual edits to libpod/lock/shm/shm_lock_test.go on top). Signed-off-by: Kir Kolyshkin <[email protected]>
Replace some uses of HasPrefix followed by TrimPrefix with CutPrefix, added to the strings package in go1.20. Brought to you by modernize -test -fix -category stringscutprefix ./... Signed-off-by: Kir Kolyshkin <[email protected]>
This way we don't check the string twice. Signed-off-by: Kir Kolyshkin <[email protected]>
Brought to you by modernize -test -fix -category=minmax ./... Signed-off-by: Kir Kolyshkin <[email protected]>
Replace []byte(fmt.Sprintf...) by fmt.Appendf(nil, ...), added in go1.19. Brought to you by modernize -test -fix -category=fmtappendf ./... Signed-off-by: Kir Kolyshkin <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kolyshkin The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
In general, changes where maps.Copy is now used are always safe, and cases where maps.Clone are used are safe as long as the original copying code was conditional to srcMap != nil or len(srcMap) != 0. Signed-off-by: Kir Kolyshkin <[email protected]>
There is a slight functional change here that may not be safe: - before this patch, if the source map is nil, the destination map will be empty (but non-nil); - after this patch, the destination map is nil if the source one is. Practically, it may or may not matter, as reading from the nil map is ok, and only changing it is not (will result in panic). Signed-off-by: Kir Kolyshkin <[email protected]>
Replace 'for i, elem := range s { if elem == needle { ...; break }' by a call to slices.Contains, added in go1.21. Brought to you by modernize -fix -test -category slicescontains ./... Signed-off-by: Kir Kolyshkin <[email protected]>
rt.storageConfig.PullOptions[k] = v | ||
} | ||
} | ||
rt.storageConfig.PullOptions = maps.Clone(config.PullOptions) |
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.
This is not equivalent, in case where rt.storageConfig.PullOptions
is already set and config.PullOptions
is nil you unset the value to nil which is not what the previos versiond oes which keeps the orignal in this case.
I think that matters because newRuntimeFromConfig() sets the default runtime.storageConfig
based on the config file so it is possible that the field has a previous value.
@@ -2,6 +2,7 @@ package main | |||
|
|||
import ( | |||
"fmt" | |||
"maps" |
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.
That is in the wrong commit at during a bisect would fail to compile.
Please see individual commits for details. High level overview:
Does this PR introduce a user-facing change?