From 53a9bcbe137b71d4e7233f07f768f1b634bd069c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 4 Sep 2026 16:30:10 +0200 Subject: [PATCH] run golangci-lint --fix In order to fix the new formatting issues reported. Signed-off-by: Paul Holzinger --- cmd/podman/machine/list.go | 2 +- cmd/podman/system/prune.go | 2 +- cmd/podman/volumes/list.go | 2 +- cmd/podman/volumes/reload.go | 2 +- libpod/kube.go | 2 +- libpod/runtime_ctr.go | 2 +- pkg/annotations/validate.go | 4 ++-- pkg/api/handlers/utils/handler.go | 8 ++++---- pkg/bindings/containers/attach.go | 6 +++--- pkg/bindings/system/system.go | 2 +- pkg/domain/infra/abi/system.go | 6 +++--- pkg/domain/utils/scp.go | 2 +- pkg/machine/e2e/list_test.go | 4 ++-- pkg/specgen/generate/oci_linux.go | 4 ++-- pkg/specgenutil/specgen.go | 2 +- pkg/specgenutil/util.go | 8 ++++---- test/e2e/play_kube_test.go | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index 922166436a..574887d45d 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -163,7 +163,7 @@ func toMachineFormat(vms []*machine.ListResponse, defaultCon *config.Connection) isDefault := false // check port, in case we somehow have machines with the same name in different providers if defaultCon != nil { - isDefault = vm.Name == defaultCon.Name && strings.Contains(defaultCon.URI, strconv.Itoa((vm.Port))) + isDefault = vm.Name == defaultCon.Name && strings.Contains(defaultCon.URI, strconv.Itoa(vm.Port)) } response := new(entities.ListReporter) response.Default = isDefault diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index 95f065715f..47c6a0abb9 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -120,7 +120,7 @@ func prune(_ *cobra.Command, _ []string) error { } if !pruneOptions.External { - fmt.Printf("Total reclaimed space: %s\n", units.HumanSize((float64)(response.ReclaimedSpace))) + fmt.Printf("Total reclaimed space: %s\n", units.HumanSize(float64(response.ReclaimedSpace))) } return nil } diff --git a/cmd/podman/volumes/list.go b/cmd/podman/volumes/list.go index 586bf0b7c5..a370ea579e 100644 --- a/cmd/podman/volumes/list.go +++ b/cmd/podman/volumes/list.go @@ -108,7 +108,7 @@ func outputTemplate(cmd *cobra.Command, responses []*entities.VolumeListReport) return err } - if (rpt.RenderHeaders) && !noHeading { + if rpt.RenderHeaders && !noHeading { if err := rpt.Execute(headers); err != nil { return fmt.Errorf("failed to write report column headers: %w", err) } diff --git a/cmd/podman/volumes/reload.go b/cmd/podman/volumes/reload.go index e103cf5196..fa20bfb96a 100644 --- a/cmd/podman/volumes/reload.go +++ b/cmd/podman/volumes/reload.go @@ -38,7 +38,7 @@ func reload(_ *cobra.Command, _ []string) error { } printReload("Added", report.Added) printReload("Removed", report.Removed) - errs := (utils.OutputErrors)(report.Errors) + errs := utils.OutputErrors(report.Errors) return errs.PrintErrors() } diff --git a/libpod/kube.go b/libpod/kube.go index 7fd362e798..9f58b74717 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -616,7 +616,7 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po } } else { for k, v := range ctr.config.Spec.Annotations { - if !podmanOnly && (define.IsReservedAnnotation(k)) { + if !podmanOnly && define.IsReservedAnnotation(k) { continue } podAnnotations[fmt.Sprintf("%s/%s", kubeAnnotationAlias(k), removeUnderscores(ctr.Name()))] = v diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index b83a3c38d7..d8035ece9f 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -1386,7 +1386,7 @@ func (r *Runtime) PruneContainers(filterFuncs []ContainerFilter) ([]*reports.Pru if err != nil { report.Err = err } else { - report.Size = (uint64)(size) + report.Size = uint64(size) } preports = append(preports, report) } diff --git a/pkg/annotations/validate.go b/pkg/annotations/validate.go index f0ab3ce57d..6e9421b939 100644 --- a/pkg/annotations/validate.go +++ b/pkg/annotations/validate.go @@ -103,9 +103,9 @@ func isQualifiedName(value string) error { func validateAnnotationsSize(annotations map[string]string) error { var totalSize int64 for k, v := range annotations { - totalSize += (int64)(len(k)) + (int64)(len(v)) + totalSize += int64(len(k)) + int64(len(v)) } - if totalSize > (int64)(define.TotalAnnotationSizeLimitB) { + if totalSize > int64(define.TotalAnnotationSizeLimitB) { return fmt.Errorf("annotations size %d is larger than limit %d", totalSize, define.TotalAnnotationSizeLimitB) } return nil diff --git a/pkg/api/handlers/utils/handler.go b/pkg/api/handlers/utils/handler.go index cd74e59949..93610cced9 100644 --- a/pkg/api/handlers/utils/handler.go +++ b/pkg/api/handlers/utils/handler.go @@ -118,7 +118,7 @@ var json = jsoniter.ConfigCompatibleWithStandardLibrary // MarshalErrorJSON writes error to stream as string func MarshalErrorJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) { - p := *((*error)(ptr)) + p := *(*error)(ptr) if p == nil { stream.WriteNil() } else { @@ -128,7 +128,7 @@ func MarshalErrorJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) { // MarshalErrorSliceJSON writes []error to stream as []string JSON blob func MarshalErrorSliceJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) { - a := *((*[]error)(ptr)) + a := *(*[]error)(ptr) switch { case len(a) == 0: stream.WriteNil() @@ -145,11 +145,11 @@ func MarshalErrorSliceJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) { } func MarshalErrorJSONIsEmpty(ptr unsafe.Pointer) bool { - return *((*error)(ptr)) == nil + return *(*error)(ptr) == nil } func MarshalErrorSliceJSONIsEmpty(ptr unsafe.Pointer) bool { - return len(*((*[]error)(ptr))) == 0 + return len(*(*[]error)(ptr)) == 0 } // ReadJSONFromBody reads JSON from a request body into the given struct. diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go index 1e0e97b99b..9233bb00f0 100644 --- a/pkg/bindings/containers/attach.go +++ b/pkg/bindings/containers/attach.go @@ -52,13 +52,13 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri } // Ensure golang can determine that interfaces are "really" nil if !isSet.stdin { - stdin = (io.Reader)(nil) + stdin = io.Reader(nil) } if !isSet.stdout { - stdout = (io.Writer)(nil) + stdout = io.Writer(nil) } if !isSet.stderr { - stderr = (io.Writer)(nil) + stderr = io.Writer(nil) } conn, err := bindings.GetClient(ctx) diff --git a/pkg/bindings/system/system.go b/pkg/bindings/system/system.go index ade08f070b..8dec60111e 100644 --- a/pkg/bindings/system/system.go +++ b/pkg/bindings/system/system.go @@ -48,7 +48,7 @@ func Events(ctx context.Context, eventChan chan types.Event, cancelChan chan boo defer response.Body.Close() defer close(eventChan) dec := json.NewDecoder(response.Body) - for err = (error)(nil); err == nil; { + for err = error(nil); err == nil; { e := types.Event{} err = dec.Decode(&e) if err == nil { diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 7ad73287a1..4c41cdb1de 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -84,7 +84,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys for k, v := range options.Filters { filters = append(filters, fmt.Sprintf("%s=%s", k, v[0])) } - reclaimedSpace := (uint64)(0) + reclaimedSpace := uint64(0) // Prune Build Containers if options.Build { @@ -114,7 +114,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys // Remove all unused containers. containerPruneOptions := entities.ContainerPruneOptions{} - containerPruneOptions.Filters = (url.Values)(options.Filters) + containerPruneOptions.Filters = url.Values(options.Filters) containerPruneReports, err := ic.ContainerPrune(ctx, containerPruneOptions) if err != nil { @@ -160,7 +160,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys // Remove unused volume data. if options.Volume { volumePruneOptions := entities.VolumePruneOptions{} - volumePruneOptions.Filters = (url.Values)(options.Filters) + volumePruneOptions.Filters = url.Values(options.Filters) if len(volumePruneOptions.Filters) == 0 { volumePruneOptions.Filters.Set("all", "true") diff --git a/pkg/domain/utils/scp.go b/pkg/domain/utils/scp.go index 8cbdd9a479..64265b076c 100644 --- a/pkg/domain/utils/scp.go +++ b/pkg/domain/utils/scp.go @@ -428,7 +428,7 @@ func ValidateSCPArgs(locations []*entities.ScpTransferImageOptions) error { // returns an int which contains the length of a specified index in a host::image string func RemoteArgLength(input string, side int) int { if strings.Contains(input, "::") { - return len((strings.Split(input, "::"))[side]) + return len(strings.Split(input, "::")[side]) } return -1 } diff --git a/pkg/machine/e2e/list_test.go b/pkg/machine/e2e/list_test.go index 724249b15c..99632fae32 100644 --- a/pkg/machine/e2e/list_test.go +++ b/pkg/machine/e2e/list_test.go @@ -87,7 +87,7 @@ var _ = Describe("podman machine list", func() { startSession, err := mb.setCmd(s).runWithoutWait() Expect(err).ToNot(HaveOccurred()) wait := 3 - retries := (int)(mb.timeout/time.Second) / wait + retries := int(mb.timeout/time.Second) / wait for range retries { listSession, err := mb.setCmd(l).run() Expect(listSession).To(Exit(0)) @@ -154,7 +154,7 @@ var _ = Describe("podman machine list", func() { Expect(session).To(Exit(0)) list := new(listMachine) - list = list.withFormat(("json")) + list = list.withFormat("json") listSession, err := mb.setCmd(list).run() Expect(err).NotTo(HaveOccurred()) var listResponse []*entities.ListReporter diff --git a/pkg/specgen/generate/oci_linux.go b/pkg/specgen/generate/oci_linux.go index a32facc6ab..4392e25249 100644 --- a/pkg/specgen/generate/oci_linux.go +++ b/pkg/specgen/generate/oci_linux.go @@ -382,8 +382,8 @@ func WeightDevices(wtDevices map[string]spec.LinuxWeightDevice) ([]spec.LinuxWei return nil, fmt.Errorf("failed to inspect '%s' in --blkio-weight-device: %w", k, err) } dev := new(spec.LinuxWeightDevice) - dev.Major = (int64(unix.Major(uint64(statT.Rdev)))) //nolint: unconvert - dev.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) //nolint: unconvert + dev.Major = int64(unix.Major(uint64(statT.Rdev))) //nolint: unconvert + dev.Minor = int64(unix.Minor(uint64(statT.Rdev))) //nolint: unconvert dev.Weight = v.Weight devs = append(devs, *dev) } diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go index f0c3dad364..a50e2aae84 100644 --- a/pkg/specgenutil/specgen.go +++ b/pkg/specgenutil/specgen.go @@ -141,7 +141,7 @@ func LimitToSwap(memory *specs.LinuxMemory, swap string, ml int64) { memory.Limit = &ml if swap == "" { limit := 2 * ml - memory.Swap = &(limit) + memory.Swap = &limit } } } diff --git a/pkg/specgenutil/util.go b/pkg/specgenutil/util.go index e9a3935e32..9fb3ed5993 100644 --- a/pkg/specgenutil/util.go +++ b/pkg/specgenutil/util.go @@ -95,7 +95,7 @@ func CreatePortBindings(ports []string) ([]types.PortMapping, error) { case 1: // No protocol was provided case 2: - proto = &(splitProto[1]) + proto = &splitProto[1] default: return nil, errors.New("invalid port format - protocol can only be specified once") } @@ -132,14 +132,14 @@ func CreatePortBindings(ports []string) ([]types.PortMapping, error) { } ctrPort = splitPort[0] case 2: - hostPort = &(splitPort[0]) + hostPort = &splitPort[0] ctrPort = splitPort[1] case 3: if haveV6 { return nil, errors.New("invalid port format - when v6 address specified, must be [ipv6]:hostPort:ctrPort") } - hostIP = &(splitPort[0]) - hostPort = &(splitPort[1]) + hostIP = &splitPort[0] + hostPort = &splitPort[1] ctrPort = splitPort[2] default: return nil, errors.New("invalid port format - format is [[hostIP:]hostPort:]containerPort") diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 212c6544cc..142e150a8d 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -5458,7 +5458,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q podmanTest.PodmanExitCleanly("kube", "play", kubeYaml, "--log-driver", "journald", "--log-opt", "tag={{.ImageName}},withcomma") podmanTest.PodmanExitCleanly("start", getCtrNameInPod(pod)) inspect := podmanTest.PodmanExitCleanly("inspect", getCtrNameInPod(pod)) - Expect((inspect.InspectContainerToJSON()[0]).HostConfig.LogConfig.Tag).To(Equal("{{.ImageName}},withcomma")) + Expect(inspect.InspectContainerToJSON()[0].HostConfig.LogConfig.Tag).To(Equal("{{.ImageName}},withcomma")) }) It("using a user namespace", func() {