.golangci.yml: add nolintlint, fix found issues

The errrolint linter can finally ignore errors from Close,
and it also ignores direct comparisons of errors from x/sys/unix.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-03-21 14:31:40 -07:00
parent 65e0f2b719
commit a638f1330b
7 changed files with 29 additions and 28 deletions
+2 -2
View File
@@ -67,7 +67,7 @@ func testCheckpoint(t *testing.T, userns bool) {
err = container.Run(&pconfig)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
pid, err := pconfig.Pid()
@@ -141,7 +141,7 @@ func testCheckpoint(t *testing.T, userns bool) {
err = container.Restore(restoreProcessConfig, checkpointOpts)
_ = restoreStdinR.Close()
defer restoreStdinW.Close() //nolint: errcheck
defer restoreStdinW.Close()
if err != nil {
t.Fatal(err)
}
+12 -12
View File
@@ -172,7 +172,7 @@ func TestEnter(t *testing.T) {
}
err = container.Run(&pconfig)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
pid, err := pconfig.Pid()
ok(t, err)
@@ -190,7 +190,7 @@ func TestEnter(t *testing.T) {
err = container.Run(&pconfig2)
_ = stdinR2.Close()
defer stdinW2.Close() //nolint: errcheck
defer stdinW2.Close()
ok(t, err)
pid2, err := pconfig2.Pid()
@@ -458,7 +458,7 @@ func testFreeze(t *testing.T, withSystemd bool, useSet bool) {
}
err = container.Run(pconfig)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
if !useSet {
@@ -738,7 +738,7 @@ func TestContainerState(t *testing.T) {
err = container.Run(p)
ok(t, err)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
st, err := container.State()
ok(t, err)
@@ -1164,7 +1164,7 @@ func TestRootfsPropagationSlaveMount(t *testing.T) {
err = container.Run(pconfig)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
// Create mnt2host under dir1host and bind mount itself on top of it.
@@ -1194,7 +1194,7 @@ func TestRootfsPropagationSlaveMount(t *testing.T) {
err = container.Run(pconfig2)
_ = stdinR2.Close()
defer stdinW2.Close() //nolint: errcheck
defer stdinW2.Close()
ok(t, err)
_ = stdinW2.Close()
@@ -1276,7 +1276,7 @@ func TestRootfsPropagationSharedMount(t *testing.T) {
err = container.Run(pconfig)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
// Create mnt2cont under dir1host. This will become visible inside container
@@ -1311,7 +1311,7 @@ func TestRootfsPropagationSharedMount(t *testing.T) {
err = container.Run(pconfig2)
_ = stdinR2.Close()
defer stdinW2.Close() //nolint: errcheck
defer stdinW2.Close()
ok(t, err)
// Wait for process
@@ -1430,7 +1430,7 @@ func TestInitJoinPID(t *testing.T) {
}
err = container1.Run(init1)
_ = stdinR1.Close()
defer stdinW1.Close() //nolint: errcheck
defer stdinW1.Close()
ok(t, err)
// get the state of the first container
@@ -1457,7 +1457,7 @@ func TestInitJoinPID(t *testing.T) {
}
err = container2.Run(init2)
_ = stdinR2.Close()
defer stdinW2.Close() //nolint: errcheck
defer stdinW2.Close()
ok(t, err)
// get the state of the second container
state2, err := container2.State()
@@ -1529,7 +1529,7 @@ func TestInitJoinNetworkAndUser(t *testing.T) {
}
err = container1.Run(init1)
_ = stdinR1.Close()
defer stdinW1.Close() //nolint: errcheck
defer stdinW1.Close()
ok(t, err)
// get the state of the first container
@@ -1563,7 +1563,7 @@ func TestInitJoinNetworkAndUser(t *testing.T) {
}
err = container2.Run(init2)
_ = stdinR2.Close()
defer stdinW2.Close() //nolint: errcheck
defer stdinW2.Close()
ok(t, err)
// get the state of the second container
+7 -7
View File
@@ -40,7 +40,7 @@ func TestExecIn(t *testing.T) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
buffers := newStdBuffers()
@@ -98,7 +98,7 @@ func testExecInRlimit(t *testing.T, userns bool) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
buffers := newStdBuffers()
@@ -149,7 +149,7 @@ func TestExecInAdditionalGroups(t *testing.T) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
var stdout bytes.Buffer
@@ -338,7 +338,7 @@ func TestExecInEnvironment(t *testing.T) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
execEnv := []string{
@@ -408,7 +408,7 @@ func TestExecinPassExtraFiles(t *testing.T) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
var stdout bytes.Buffer
@@ -473,7 +473,7 @@ func TestExecInOomScoreAdj(t *testing.T) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
buffers := newStdBuffers()
@@ -521,7 +521,7 @@ func TestExecInUserns(t *testing.T) {
}
err = container.Run(process)
_ = stdinR.Close()
defer stdinW.Close() //nolint: errcheck
defer stdinW.Close()
ok(t, err)
initPID, err := process.Pid()