Skip to content

Commit 9d40a56

Browse files
authored
Merge pull request #338 from skitt/cleanup-post-go-1.23
Fix golangci-lint and remove obsolete Go-version-based alternatives
2 parents 98d557b + 66458b5 commit 9d40a56

File tree

8 files changed

+34
-140
lines changed

8 files changed

+34
-140
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ jobs:
5757
runs-on: ubuntu-latest
5858
steps:
5959
- name: Install Go
60-
uses: actions/setup-go@v3
60+
uses: actions/setup-go@v6
61+
with:
62+
go-version: v1.23
6163
- name: Checkout code
62-
uses: actions/checkout@v2
64+
uses: actions/checkout@v5
6365
- name: Lint
64-
run: |
65-
docker run --rm -v `pwd`:/go/src/k8s.io/klog -w /go/src/k8s.io/klog \
66-
golangci/golangci-lint:v1.51.2 golangci-lint run --disable-all -v \
67-
-E govet -E misspell -E gofmt -E ineffassign -E golint
66+
uses: golangci/golangci-lint-action@v6
67+
with:
68+
version: v1.60.1
69+
args: --disable-all -v -E govet -E misspell -E gofmt -E ineffassign
6870
apidiff:
6971
runs-on: ubuntu-latest
7072
if: github.base_ref

exec/exec.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package exec
1818

1919
import (
2020
"context"
21+
"errors"
2122
"io"
2223
"io/fs"
2324
osexec "os/exec"
@@ -97,6 +98,21 @@ func New() Interface {
9798
return &executor{}
9899
}
99100

101+
// maskErrDotCmd reverts the behavior of osexec.Cmd to what it was before go1.19
102+
// specifically set the Err field to nil (LookPath returns a new error when the file
103+
// is resolved to the current directory.
104+
func maskErrDotCmd(cmd *osexec.Cmd) *osexec.Cmd {
105+
cmd.Err = maskErrDot(cmd.Err)
106+
return cmd
107+
}
108+
109+
func maskErrDot(err error) error {
110+
if err != nil && errors.Is(err, osexec.ErrDot) {
111+
return nil
112+
}
113+
return err
114+
}
115+
100116
// Command is part of the Interface interface.
101117
func (executor *executor) Command(cmd string, args ...string) Cmd {
102118
return (*cmdWrapper)(maskErrDotCmd(osexec.Command(cmd, args...)))

exec/fixup_go118.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

exec/fixup_go119.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

mount/mount_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target
371371
sensitiveOptionsLog := sanitizedOptionsForLogging(options, sensitiveOptions)
372372
detailedErr := fmt.Sprintf("format of disk %q failed: type:(%q) target:(%q) options:(%q) errcode:(%v) output:(%v) ", source, fstype, target, sensitiveOptionsLog, err, string(output))
373373
klog.Error(detailedErr)
374-
return NewMountError(FormatFailed, detailedErr)
374+
return NewMountError(FormatFailed, "%s", detailedErr)
375375
}
376376

377377
klog.Infof("Disk successfully formatted (mkfs): %s - %s %s", fstype, source, target)
@@ -394,7 +394,7 @@ func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target
394394
// Mount the disk
395395
klog.V(4).Infof("Attempting to mount disk %s in %s format at %s", source, fstype, target)
396396
if err := mounter.MountSensitive(source, target, fstype, options, sensitiveOptions); err != nil {
397-
return NewMountError(mountErrorValue, err.Error())
397+
return NewMountError(mountErrorValue, "%s", err.Error())
398398
}
399399

400400
return nil

set/set.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ func New[E ordered](items ...E) Set[E] {
3434
return ss
3535
}
3636

37+
// Clear empties the set.
38+
// It is preferable to replace the set with a newly constructed set,
39+
// but not all callers can do that (when there are other references to the map).
40+
func (s Set[T]) Clear() Set[T] {
41+
clear(s)
42+
return s
43+
}
44+
3745
// KeySet creates a Set[E] from a keys of a map[E](? extends interface{}).
3846
func KeySet[E ordered, A any](theMap map[E]A) Set[E] {
3947
ret := Set[E]{}

set/set_go_1.20.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

set/set_go_1.21.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)