Skip to content

Commit 66458b5

Browse files
committed
Remove obsolete Go-version-based alternatives
Since utils requires Go 1.23, code specifically for older versions is no longer necessary. Signed-off-by: Stephen Kitt <skitt@redhat.com>
1 parent fddd6ef commit 66458b5

File tree

6 files changed

+24
-132
lines changed

6 files changed

+24
-132
lines changed

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.

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)