mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 00:15:44 +00:00
Fix GOOS=windows prealloc linter warnings
These ones:
> cmd/winpath/main.go:148:2: directive `//nolint:prealloc` is unused for linter "prealloc" (nolintlint)
> //nolint:prealloc
> ^
> pkg/machine/hyperv/vsock/vsock.go:425:2: Consider preallocating allSocks (prealloc)
> allSocks := []*HVSockRegistryEntry{}
> ^
> pkg/machine/wsl/machine.go:464:2: Consider preallocating newArgs with capacity 4 + len(arg) (prealloc)
> newArgs := []string{"-u", "root", "-d", dist}
> ^
> pkg/machine/wsl/machine.go:471:2: Consider preallocating newArgs with capacity 4 + len(arg) (prealloc)
> newArgs := []string{"-u", "root", "-d", dist}
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
3c3d32718f
commit
f9002cfd31
3 changed files with 12 additions and 9 deletions
|
|
@ -144,8 +144,6 @@ func removePathFromRegistry(path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// No point preallocating we can't know how big the array needs to be.
|
||||
//nolint:prealloc
|
||||
var elements []string
|
||||
for element := range strings.SplitSeq(existing, ";") {
|
||||
if strings.EqualFold(element, path) {
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ func RemoveAllHVSockRegistryEntries() error {
|
|||
return err
|
||||
}
|
||||
|
||||
allSocks := []*HVSockRegistryEntry{}
|
||||
allSocks := make([]*HVSockRegistryEntry, 0, len(networkSocks)+len(eventsSocks)+len(fileserverSocks))
|
||||
allSocks = append(allSocks, networkSocks...)
|
||||
allSocks = append(allSocks, eventsSocks...)
|
||||
allSocks = append(allSocks, fileserverSocks...)
|
||||
|
|
|
|||
|
|
@ -460,17 +460,22 @@ func withUser(s string, user string) string {
|
|||
return strings.ReplaceAll(s, "[USER]", user)
|
||||
}
|
||||
|
||||
func wslInvoke(dist string, arg ...string) error {
|
||||
newArgs := []string{"-u", "root", "-d", dist}
|
||||
func wslCmd(dist string, arg ...string) *exec.Cmd {
|
||||
preArgs := []string{"-u", "root", "-d", dist}
|
||||
newArgs := make([]string, 0, len(preArgs)+len(arg))
|
||||
newArgs = append(newArgs, preArgs...)
|
||||
newArgs = append(newArgs, arg...)
|
||||
cmd := wutil.NewWSLCommand(newArgs...)
|
||||
|
||||
return wutil.NewWSLCommand(newArgs...)
|
||||
}
|
||||
|
||||
func wslInvoke(dist string, arg ...string) error {
|
||||
cmd := wslCmd(dist, arg...)
|
||||
return runCmdPassThrough(cmd)
|
||||
}
|
||||
|
||||
func wslPipe(input string, dist string, arg ...string) error {
|
||||
newArgs := []string{"-u", "root", "-d", dist}
|
||||
newArgs = append(newArgs, arg...)
|
||||
cmd := wutil.NewWSLCommand(newArgs...)
|
||||
cmd := wslCmd(dist, arg...)
|
||||
return pipeCmdPassThrough(cmd, input)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue