Skip to content

Commit

Permalink
ci(lint): enable errcheck, errorlint, gci, misspell, nonamedreturns a…
Browse files Browse the repository at this point in the history
…nd staticcheck linters (#71)

Enable the following linters:
  - errcheck
  - errorlint
  - gci
  - misspell
  - nonamedreturns
  - staticcheck

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 authored Mar 26, 2023
1 parent 5992098 commit 364b2a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
linters:
enable:
- errcheck
- errorlint
- gci
- misspell
- nonamedreturns
- staticcheck

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/vishvananda)

run:
timeout: 5m
8 changes: 4 additions & 4 deletions netns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ const bindMountPath = "/run/netns" /* Bind mount path for named netns */
// Setns sets namespace using golang.org/x/sys/unix.Setns.
//
// Deprecated: Use golang.org/x/sys/unix.Setns instead.
func Setns(ns NsHandle, nstype int) (err error) {
func Setns(ns NsHandle, nstype int) error {
return unix.Setns(int(ns), nstype)
}

// Set sets the current network namespace to the namespace represented
// by NsHandle.
func Set(ns NsHandle) (err error) {
func Set(ns NsHandle) error {
return unix.Setns(int(ns), unix.CLONE_NEWNET)
}

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

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

return pid, nil
Expand Down
8 changes: 4 additions & 4 deletions netns_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ var (
// is not implemented on other platforms.
//
// Deprecated: Use golang.org/x/sys/unix.Setns instead.
func Setns(ns NsHandle, nstype int) (err error) {
func Setns(ns NsHandle, nstype int) error {
return ErrNotImplemented
}

func Set(ns NsHandle) (err error) {
func Set(ns NsHandle) error {
return ErrNotImplemented
}

func New() (ns NsHandle, err error) {
func New() (NsHandle, error) {
return -1, ErrNotImplemented
}

Expand Down Expand Up @@ -51,7 +51,7 @@ func GetFromPid(pid int) (NsHandle, error) {
return -1, ErrNotImplemented
}

func GetFromThread(pid, tid int) (NsHandle, error) {
func GetFromThread(pid int, tid int) (NsHandle, error) {
return -1, ErrNotImplemented
}

Expand Down

0 comments on commit 364b2a2

Please sign in to comment.