Skip to content

Commit e729cb1

Browse files
committed
run modernize -fix ./...
Using golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize Signed-off-by: Paul Holzinger <[email protected]>
1 parent 2f9c2c6 commit e729cb1

File tree

144 files changed

+500
-620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+500
-620
lines changed

cmd/podman/common/build.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"io"
7+
"maps"
78
"os"
89
"path/filepath"
910
"strconv"
@@ -337,9 +338,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
337338
if err != nil {
338339
return nil, err
339340
}
340-
for name, val := range fargs {
341-
args[name] = val
342-
}
341+
maps.Copy(args, fargs)
343342
}
344343
}
345344
if c.Flag("build-arg").Changed {

cmd/podman/common/completion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ func convertFormatSuggestions(suggestions []formatSuggestion) []string {
13651365
// This function will only work for pointer to structs other types are not supported.
13661366
// When "{{." is typed the field and method names of the given struct will be completed.
13671367
// This also works recursive for nested structs.
1368-
func AutocompleteFormat(o interface{}) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
1368+
func AutocompleteFormat(o any) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
13691369
// this function provides shell completion for go templates
13701370
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
13711371
// autocomplete json when nothing or json is typed
@@ -1454,7 +1454,7 @@ func AutocompleteFormat(o interface{}) func(cmd *cobra.Command, args []string, t
14541454
}
14551455
}
14561456

1457-
func getEntityType(cmd *cobra.Command, args []string, o interface{}) interface{} {
1457+
func getEntityType(cmd *cobra.Command, args []string, o any) any {
14581458
// container logic
14591459
if containers, _ := getContainers(cmd, args[0], completeDefault); len(containers) > 0 {
14601460
return &define.InspectContainerData{}

cmd/podman/images/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func imageSearch(cmd *cobra.Command, args []string) error {
212212
return rpt.Execute(searchReport)
213213
}
214214

215-
func printArbitraryJSON(v interface{}) error {
215+
func printArbitraryJSON(v any) error {
216216
prettyJSON, err := json.MarshalIndent(v, "", " ")
217217
if err != nil {
218218
return err

cmd/podman/inspect/inspect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func newInspector(options entities.InspectOptions) (*inspector, error) {
7676
// inspect inspects the specified container/image names or IDs.
7777
func (i *inspector) inspect(namesOrIDs []string) error {
7878
// data - dumping place for inspection results.
79-
var data []interface{}
79+
var data []any
8080
var errs []error
8181
ctx := context.Background()
8282

@@ -157,7 +157,7 @@ func (i *inspector) inspect(namesOrIDs []string) error {
157157
}
158158
// Always print an empty array
159159
if data == nil {
160-
data = []interface{}{}
160+
data = []any{}
161161
}
162162

163163
var err error
@@ -191,8 +191,8 @@ func (i *inspector) inspect(namesOrIDs []string) error {
191191
return nil
192192
}
193193

194-
func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]interface{}, []error, error) {
195-
var data []interface{}
194+
func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]any, []error, error) {
195+
var data []any
196196
allErrs := []error{}
197197
for _, name := range namesOrIDs {
198198
ctrData, errs, err := i.containerEngine.ContainerInspect(ctx, []string{name}, i.options)

cmd/podman/machine/client9p.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func client9p(portNum uint32, mountPath string) error {
7676
conn *vsock.Conn
7777
retries = 20
7878
)
79-
for i := 0; i < retries; i++ {
79+
for range retries {
8080
// Host connects to non-hypervisor processes on the host running the VM.
8181
conn, err = vsock.Dial(vsock.Host, portNum, nil)
8282
// If errors.Is worked on this error, we could detect non-timeout errors.

cmd/podman/machine/os/manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ func GetDistribution() Distribution {
8989

9090
l := bufio.NewScanner(f)
9191
for l.Scan() {
92-
if strings.HasPrefix(l.Text(), "ID=") {
93-
dist.Name = strings.TrimPrefix(l.Text(), "ID=")
92+
if after, ok := strings.CutPrefix(l.Text(), "ID="); ok {
93+
dist.Name = after
9494
}
95-
if strings.HasPrefix(l.Text(), "VARIANT_ID=") {
96-
dist.Variant = strings.Trim(strings.TrimPrefix(l.Text(), "VARIANT_ID="), "\"")
95+
if after, ok := strings.CutPrefix(l.Text(), "VARIANT_ID="); ok {
96+
dist.Variant = strings.Trim(after, "\"")
9797
}
9898
}
9999
return dist

cmd/podman/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ import (
3838

3939
type logrusLogger struct{}
4040

41-
func (l logrusLogger) Errorf(format string, args ...interface{}) {
41+
func (l logrusLogger) Errorf(format string, args ...any) {
4242
logrus.Errorf(format, args...)
4343
}
44-
func (l logrusLogger) Debugf(format string, args ...interface{}) {
44+
func (l logrusLogger) Debugf(format string, args ...any) {
4545
logrus.Debugf(format, args...)
4646
}
4747

cmd/podman/quadlet/quadlet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
// logrusLogger implements the logiface.Logger interface using logrus
1212
type logrusLogger struct{}
1313

14-
func (l logrusLogger) Errorf(format string, args ...interface{}) {
14+
func (l logrusLogger) Errorf(format string, args ...any) {
1515
logrus.Errorf(format, args...)
1616
}
1717

18-
func (l logrusLogger) Debugf(format string, args ...interface{}) {
18+
func (l logrusLogger) Debugf(format string, args ...any) {
1919
logrus.Debugf(format, args...)
2020
}
2121

cmd/podman/root.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99
"runtime"
1010
"runtime/pprof"
11+
"slices"
1112
"strconv"
1213
"strings"
1314

@@ -452,11 +453,8 @@ func loggingHook() {
452453
}
453454
logLevel = "debug"
454455
}
455-
for _, l := range common.LogLevels {
456-
if l == strings.ToLower(logLevel) {
457-
found = true
458-
break
459-
}
456+
if slices.Contains(common.LogLevels, strings.ToLower(logLevel)) {
457+
found = true
460458
}
461459
if !found {
462460
fmt.Fprintf(os.Stderr, "Log Level %q is not supported, choose from: %s\n", logLevel, strings.Join(common.LogLevels, ", "))

cmd/podman/system/df.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func printVerbose(cmd *cobra.Command, reports *entities.SystemDfReport) error {
233233
return writeTemplate(rpt, hdrs, dfVolumes)
234234
}
235235

236-
func writeTemplate(rpt *report.Formatter, hdrs []map[string]string, output interface{}) error {
236+
func writeTemplate(rpt *report.Formatter, hdrs []map[string]string, output any) error {
237237
if rpt.RenderHeaders {
238238
if err := rpt.Execute(hdrs); err != nil {
239239
return err

0 commit comments

Comments
 (0)