Skip to content

Commit 0ba4a18

Browse files
authored
Merge pull request #3681 from alexandear-org/chore/lint-unconvert
chore: Enable unconvert linter
2 parents 53d7186 + e88664d commit 0ba4a18

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ linters:
2525
- perfsprint
2626
- revive
2727
- staticcheck
28+
- unconvert
2829
- unused
2930
- usetesting
3031
- whitespace

pkg/imgutil/nativeimgutil/nativeimgutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (n *NativeImageUtil) CreateDisk(disk string, size int64) error {
163163
}
164164
defer f.Close()
165165
roundedSize := roundUp(size)
166-
return f.Truncate(int64(roundedSize))
166+
return f.Truncate(roundedSize)
167167
}
168168

169169
// ConvertToRaw converts a disk image to raw format.

pkg/store/instance_windows.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,16 @@ func GetWslStatus(instName string) (string, error) {
7272
"--verbose",
7373
})
7474
if err != nil {
75-
return "", fmt.Errorf("failed to run `wsl --list --verbose`, err: %w (out=%q)", err, string(out))
75+
return "", fmt.Errorf("failed to run `wsl --list --verbose`, err: %w (out=%q)", err, out)
7676
}
7777

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

8282
// Check for edge cases first
83-
outString := string(out)
84-
if strings.Contains(outString, "Windows Subsystem for Linux has no installed distributions.") {
85-
if strings.Contains(outString, "Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND") {
83+
if strings.Contains(out, "Windows Subsystem for Linux has no installed distributions.") {
84+
if strings.Contains(out, "Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND") {
8685
return StatusBroken, fmt.Errorf(
8786
"failed to read instance state for instance %q because no distro is installed,"+
8887
"try running `wsl --install -d Ubuntu` and then re-running Lima", instName)
@@ -96,7 +95,7 @@ func GetWslStatus(instName string) (string, error) {
9695
var instState string
9796
wslListColsRegex := regexp.MustCompile(`\s+`)
9897
// wsl --list --verbose may have different headers depending on localization, just split by line
99-
for _, rows := range strings.Split(strings.ReplaceAll(string(out), "\r\n", "\n"), "\n") {
98+
for _, rows := range strings.Split(strings.ReplaceAll(out, "\r\n", "\n"), "\n") {
10099
cols := wslListColsRegex.Split(strings.TrimSpace(rows), -1)
101100
nameIdx := 0
102101
// '*' indicates default instance

pkg/windows/process_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func GetProcessCommandLine(name string) ([]string, error) {
2929
}
3030

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

pkg/wsl2/vm_windows.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func startVM(ctx context.Context, distroName string) error {
3030
}, executil.WithContext(ctx))
3131
if err != nil {
3232
return fmt.Errorf("failed to run `wsl.exe --distribution %s`: %w (out=%q)",
33-
distroName, err, string(out))
33+
distroName, err, out)
3434
}
3535
return nil
3636
}
@@ -48,7 +48,7 @@ func initVM(ctx context.Context, instanceDir, distroName string) error {
4848
}, executil.WithContext(ctx))
4949
if err != nil {
5050
return fmt.Errorf("failed to run `wsl.exe --import %s %s %s`: %w (out=%q)",
51-
distroName, instanceDir, baseDisk, err, string(out))
51+
distroName, instanceDir, baseDisk, err, out)
5252
}
5353
return nil
5454
}
@@ -62,7 +62,7 @@ func stopVM(ctx context.Context, distroName string) error {
6262
}, executil.WithContext(ctx))
6363
if err != nil {
6464
return fmt.Errorf("failed to run `wsl.exe --terminate %s`: %w (out=%q)",
65-
distroName, err, string(out))
65+
distroName, err, out)
6666
}
6767
return nil
6868
}
@@ -172,7 +172,7 @@ func unregisterVM(ctx context.Context, distroName string) error {
172172
}, executil.WithContext(ctx))
173173
if err != nil {
174174
return fmt.Errorf("failed to run `wsl.exe --unregister %s`: %w (out=%q)",
175-
distroName, err, string(out))
175+
distroName, err, out)
176176
}
177177
return nil
178178
}

0 commit comments

Comments
 (0)