Skip to content

Commit

Permalink
Merge pull request #7578 from mook-as/golang-ci-lint/round-2.1
Browse files Browse the repository at this point in the history
More golangci-lint fixes
  • Loading branch information
jandubois authored Oct 3, 2024
2 parents dcbb441 + 819557f commit 501db92
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/config/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ linters-settings:
- ^os\.Mkdir(?:All)?$
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
Expand All @@ -53,14 +51,16 @@ linters:
disable-all: true
enable:
- bodyclose
- copyloopvar
- dogsled
- errcheck
- exportloopref
- goconst
- gofmt
- goimports
- goprintffuncname
- gosimple
- ineffassign
- misspell
- typecheck
- unconvert
- unused
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Ensure you have the following installed:

- [yarn classic][yarn-classic]

- Go 1.21 or later.
- Go 1.22 or later.

- Dependencies described in the [`node-gyp` docs][node-gyp] installation.
This is required to install the [`ffi-napi`][ffi-napi] npm package. These docs mention
Expand Down
4 changes: 3 additions & 1 deletion scripts/lint-go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ async function goLangCILint(fix: boolean): Promise<boolean> {
// this is necessary). To be safe, just pass in all of the modules at once
// and let it go at its own pace.
const modules = await getModules();
const commandLine = ['go', ...args, ...modules.map(m => `${ m }/...`)];

try {
await spawnFile('go', [...args, ...modules.map(m => `${ m }/...`)], { stdio: 'inherit' });
console.log(commandLine.join(' '));
await spawnFile(commandLine[0], commandLine.slice(1), { stdio: 'inherit' });
} catch (ex) {
success = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/go/docker-credential-none/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher-sandbox/rancher-desktop/src/go/docker-credential-none

go 1.21
go 1.22

require (
github.com/docker/cli v27.3.1+incompatible
Expand Down
2 changes: 1 addition & 1 deletion src/go/extension-proxy/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/rancher-sandbox/rancher-desktop/src/go/extension-port-forwarder

go 1.21
go 1.22
2 changes: 1 addition & 1 deletion src/go/github-runner-monitor/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher-sandbox/rancher-desktop/src/go/github-runner-monitor

go 1.21
go 1.22

require (
github.com/google/go-github/v55 v55.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/go/mock-wsl/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher-sandbox/rancher-desktop/e2e/assets/mock-wsl

go 1.21
go 1.22

require (
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
Expand Down
2 changes: 1 addition & 1 deletion src/go/nerdctl-stub/generate/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher-sandbox/rancher-desktop/src/go/nerdctl-stub/generate

go 1.21
go 1.22

require github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af

Expand Down
2 changes: 1 addition & 1 deletion src/go/nerdctl-stub/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher-sandbox/rancher-desktop/src/go/nerdctl-stub

go 1.21
go 1.22

require (
github.com/hashicorp/go-multierror v1.1.1
Expand Down
2 changes: 1 addition & 1 deletion src/go/rdctl/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher-sandbox/rancher-desktop/src/go/rdctl

go 1.21
go 1.22

require (
github.com/adrg/xdg v0.5.0
Expand Down
2 changes: 0 additions & 2 deletions src/go/rdctl/pkg/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func TestTaskRunner(t *testing.T) {
taskRunner := NewTaskRunner(ctx)
runOrder := make([]int, 0, 3)
for i := 1; i < 4; i++ {
i := i
taskRunner.Add(func() error {
runOrder = append(runOrder, i)
return nil
Expand Down Expand Up @@ -66,7 +65,6 @@ func TestTaskRunner(t *testing.T) {
expectedError := "func1 error"
ranSlice := make([]bool, 2)
for i := range ranSlice {
i := i
taskRunner.Add(func() error {
ranSlice[i] = true
t.Logf("func%d ran", i+1)
Expand Down
2 changes: 0 additions & 2 deletions src/go/rdctl/pkg/snapshot/snapshotter_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (snapshotter SnapshotterImpl) CreateFiles(ctx context.Context, appPaths pat
taskRunner := runner.NewTaskRunner(ctx)
files := snapshotter.Files(appPaths, snapshotDir)
for _, file := range files {
file := file
taskRunner.Add(func() error {
err := copyFile(file.SnapshotPath, file.WorkingPath, file.CopyOnWrite, file.FileMode)
if errors.Is(err, os.ErrNotExist) && file.MissingOk {
Expand Down Expand Up @@ -126,7 +125,6 @@ func (snapshotter SnapshotterImpl) RestoreFiles(ctx context.Context, appPaths pa
taskRunner := runner.NewTaskRunner(ctx)
files := snapshotter.Files(appPaths, snapshotDir)
for _, file := range files {
file := file
taskRunner.Add(func() error {
filename := filepath.Base(file.WorkingPath)
err := copyFile(file.WorkingPath, file.SnapshotPath, file.CopyOnWrite, file.FileMode)
Expand Down
2 changes: 0 additions & 2 deletions src/go/rdctl/pkg/snapshot/snapshotter_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func (snapshotter SnapshotterImpl) CreateFiles(ctx context.Context, appPaths pat

// export WSL distros to snapshot directory
for _, distro := range snapshotter.WSLDistros(appPaths) {
distro := distro
taskRunner.Add(func() error {
snapshotDistroPath := filepath.Join(snapshotDir, distro.Name+".tar")
if err := snapshotter.ExportDistro(distro.Name, snapshotDistroPath); err != nil {
Expand Down Expand Up @@ -119,7 +118,6 @@ func (snapshotter SnapshotterImpl) RestoreFiles(ctx context.Context, appPaths pa

// restore WSL distros
for _, distro := range snapshotter.WSLDistros(appPaths) {
distro := distro
tr.Add(func() error {
snapshotDistroPath := filepath.Join(snapshotDir, distro.Name+".tar")
if err := os.MkdirAll(distro.WorkingDirPath, 0o755); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions src/go/wsl-helper/pkg/wsl-utils/version_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func TestPackageVersion(t *testing.T) {
{L: "1.0.0", R: "0.0.1", expect: false},
}
for _, input := range cases {
input := input
t.Run(fmt.Sprintf("%s<%s=%v", input.L, input.R, input.expect), func(t *testing.T) {
var left, right PackageVersion
assert.NoError(t, left.UnmarshalText([]byte(input.L)))
Expand Down Expand Up @@ -175,8 +174,6 @@ func TestGetVersionFromCLI(t *testing.T) {
logger.SetOutput(io.Discard)

for name, input := range outputs {
name := name
input := input
t.Run(name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
Expand Down

0 comments on commit 501db92

Please sign in to comment.