Skip to content

Commit 364b2a2

Browse files
authored
ci(lint): enable errcheck, errorlint, gci, misspell, nonamedreturns and staticcheck linters (#71)
Enable the following linters: - errcheck - errorlint - gci - misspell - nonamedreturns - staticcheck Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 5992098 commit 364b2a2

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

Diff for: .golangci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1+
linters:
2+
enable:
3+
- errcheck
4+
- errorlint
5+
- gci
6+
- misspell
7+
- nonamedreturns
8+
- staticcheck
9+
10+
linters-settings:
11+
gci:
12+
sections:
13+
- standard
14+
- default
15+
- prefix(github.com/vishvananda)
16+
117
run:
218
timeout: 5m

Diff for: netns_linux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ const bindMountPath = "/run/netns" /* Bind mount path for named netns */
2626
// Setns sets namespace using golang.org/x/sys/unix.Setns.
2727
//
2828
// Deprecated: Use golang.org/x/sys/unix.Setns instead.
29-
func Setns(ns NsHandle, nstype int) (err error) {
29+
func Setns(ns NsHandle, nstype int) error {
3030
return unix.Setns(int(ns), nstype)
3131
}
3232

3333
// Set sets the current network namespace to the namespace represented
3434
// by NsHandle.
35-
func Set(ns NsHandle) (err error) {
35+
func Set(ns NsHandle) error {
3636
return unix.Setns(int(ns), unix.CLONE_NEWNET)
3737
}
3838

3939
// New creates a new network namespace, sets it as current and returns
4040
// a handle to it.
41-
func New() (ns NsHandle, err error) {
41+
func New() (NsHandle, error) {
4242
if err := unix.Unshare(unix.CLONE_NEWNET); err != nil {
4343
return -1, err
4444
}
@@ -276,7 +276,7 @@ func getPidForContainer(id string) (int, error) {
276276

277277
pid, err = strconv.Atoi(result[0])
278278
if err != nil {
279-
return pid, fmt.Errorf("Invalid pid '%s': %s", result[0], err)
279+
return pid, fmt.Errorf("Invalid pid '%s': %w", result[0], err)
280280
}
281281

282282
return pid, nil

Diff for: netns_others.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ var (
1515
// is not implemented on other platforms.
1616
//
1717
// Deprecated: Use golang.org/x/sys/unix.Setns instead.
18-
func Setns(ns NsHandle, nstype int) (err error) {
18+
func Setns(ns NsHandle, nstype int) error {
1919
return ErrNotImplemented
2020
}
2121

22-
func Set(ns NsHandle) (err error) {
22+
func Set(ns NsHandle) error {
2323
return ErrNotImplemented
2424
}
2525

26-
func New() (ns NsHandle, err error) {
26+
func New() (NsHandle, error) {
2727
return -1, ErrNotImplemented
2828
}
2929

@@ -51,7 +51,7 @@ func GetFromPid(pid int) (NsHandle, error) {
5151
return -1, ErrNotImplemented
5252
}
5353

54-
func GetFromThread(pid, tid int) (NsHandle, error) {
54+
func GetFromThread(pid int, tid int) (NsHandle, error) {
5555
return -1, ErrNotImplemented
5656
}
5757

0 commit comments

Comments
 (0)