Skip to content

Commit df76f81

Browse files
authored
enable gocritic, gosec, gosimple, govet unconvert, unparam, unused and whitespace linters (#72)
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 364b2a2 commit df76f81

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.golangci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ linters:
22
enable:
33
- errcheck
44
- errorlint
5+
- gocritic
6+
- gosec
7+
- gosimple
8+
- govet
59
- gci
610
- misspell
711
- nonamedreturns
812
- staticcheck
13+
- unconvert
14+
- unparam
15+
- unused
16+
- whitespace
917

1018
linters-settings:
1119
gci:

netns_linux.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func New() (NsHandle, error) {
4949
// and returns a handle to it
5050
func NewNamed(name string) (NsHandle, error) {
5151
if _, err := os.Stat(bindMountPath); os.IsNotExist(err) {
52-
err = os.MkdirAll(bindMountPath, 0755)
52+
err = os.MkdirAll(bindMountPath, 0o755)
5353
if err != nil {
5454
return None(), err
5555
}
@@ -62,7 +62,7 @@ func NewNamed(name string) (NsHandle, error) {
6262

6363
namedPath := path.Join(bindMountPath, name)
6464

65-
f, err := os.OpenFile(namedPath, os.O_CREATE|os.O_EXCL, 0444)
65+
f, err := os.OpenFile(namedPath, os.O_CREATE|os.O_EXCL, 0o444)
6666
if err != nil {
6767
newNs.Close()
6868
return None(), err
@@ -217,11 +217,12 @@ func getPidForContainer(id string) (int, error) {
217217
id += "*"
218218

219219
var pidFile string
220-
if cgroupVer == 1 {
220+
switch cgroupVer {
221+
case 1:
221222
pidFile = "tasks"
222-
} else if cgroupVer == 2 {
223+
case 2:
223224
pidFile = "cgroup.procs"
224-
} else {
225+
default:
225226
return -1, fmt.Errorf("Invalid cgroup version '%d'", cgroupVer)
226227
}
227228

netns_others.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33

44
package netns
55

6-
import (
7-
"errors"
8-
)
6+
import "errors"
97

10-
var (
11-
ErrNotImplemented = errors.New("not implemented")
12-
)
8+
var ErrNotImplemented = errors.New("not implemented")
139

1410
// Setns sets namespace using golang.org/x/sys/unix.Setns on Linux. It
1511
// is not implemented on other platforms.

0 commit comments

Comments
 (0)