Skip to content

chore: Enable unconvert linter #3681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ linters:
- perfsprint
- revive
- staticcheck
- unconvert
- unused
- usetesting
- whitespace
Expand Down
2 changes: 1 addition & 1 deletion pkg/imgutil/nativeimgutil/nativeimgutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (n *NativeImageUtil) CreateDisk(disk string, size int64) error {
}
defer f.Close()
roundedSize := roundUp(size)
return f.Truncate(int64(roundedSize))
return f.Truncate(roundedSize)
}

// ConvertToRaw converts a disk image to raw format.
Expand Down
9 changes: 4 additions & 5 deletions pkg/store/instance_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,16 @@ func GetWslStatus(instName string) (string, error) {
"--verbose",
})
if err != nil {
return "", fmt.Errorf("failed to run `wsl --list --verbose`, err: %w (out=%q)", err, string(out))
return "", fmt.Errorf("failed to run `wsl --list --verbose`, err: %w (out=%q)", err, out)
}

if out == "" {
return StatusBroken, fmt.Errorf("failed to read instance state for instance %q, try running `wsl --list --verbose` to debug, err: %w", instName, err)
}

// Check for edge cases first
outString := string(out)
if strings.Contains(outString, "Windows Subsystem for Linux has no installed distributions.") {
if strings.Contains(outString, "Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND") {
if strings.Contains(out, "Windows Subsystem for Linux has no installed distributions.") {
if strings.Contains(out, "Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND") {
return StatusBroken, fmt.Errorf(
"failed to read instance state for instance %q because no distro is installed,"+
"try running `wsl --install -d Ubuntu` and then re-running Lima", instName)
Expand All @@ -96,7 +95,7 @@ func GetWslStatus(instName string) (string, error) {
var instState string
wslListColsRegex := regexp.MustCompile(`\s+`)
// wsl --list --verbose may have different headers depending on localization, just split by line
for _, rows := range strings.Split(strings.ReplaceAll(string(out), "\r\n", "\n"), "\n") {
for _, rows := range strings.Split(strings.ReplaceAll(out, "\r\n", "\n"), "\n") {
cols := wslListColsRegex.Split(strings.TrimSpace(rows), -1)
nameIdx := 0
// '*' indicates default instance
Expand Down
2 changes: 1 addition & 1 deletion pkg/windows/process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func GetProcessCommandLine(name string) ([]string, error) {
}

var outJSON CommandLineJSON
if err = json.Unmarshal([]byte(out), &outJSON); err != nil {
if err = json.Unmarshal(out, &outJSON); err != nil {
return nil, fmt.Errorf("failed to unmarshal %q as %T: %w", out, outJSON, err)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/wsl2/vm_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func startVM(ctx context.Context, distroName string) error {
}, executil.WithContext(ctx))
if err != nil {
return fmt.Errorf("failed to run `wsl.exe --distribution %s`: %w (out=%q)",
distroName, err, string(out))
distroName, err, out)
}
return nil
}
Expand All @@ -48,7 +48,7 @@ func initVM(ctx context.Context, instanceDir, distroName string) error {
}, executil.WithContext(ctx))
if err != nil {
return fmt.Errorf("failed to run `wsl.exe --import %s %s %s`: %w (out=%q)",
distroName, instanceDir, baseDisk, err, string(out))
distroName, instanceDir, baseDisk, err, out)
}
return nil
}
Expand All @@ -62,7 +62,7 @@ func stopVM(ctx context.Context, distroName string) error {
}, executil.WithContext(ctx))
if err != nil {
return fmt.Errorf("failed to run `wsl.exe --terminate %s`: %w (out=%q)",
distroName, err, string(out))
distroName, err, out)
}
return nil
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func unregisterVM(ctx context.Context, distroName string) error {
}, executil.WithContext(ctx))
if err != nil {
return fmt.Errorf("failed to run `wsl.exe --unregister %s`: %w (out=%q)",
distroName, err, string(out))
distroName, err, out)
}
return nil
}
Loading