Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable gocritic, gosec, gosimple, govet, unconvert, unparam, unused and whitespace linters #72

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ linters:
enable:
- errcheck
- errorlint
- gocritic
- gosec
- gosimple
- govet
- gci
- misspell
- nonamedreturns
- staticcheck
- unconvert
- unparam
- unused
- whitespace

linters-settings:
gci:
Expand Down
11 changes: 6 additions & 5 deletions netns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func New() (NsHandle, error) {
// and returns a handle to it
func NewNamed(name string) (NsHandle, error) {
if _, err := os.Stat(bindMountPath); os.IsNotExist(err) {
err = os.MkdirAll(bindMountPath, 0755)
err = os.MkdirAll(bindMountPath, 0o755)
if err != nil {
return None(), err
}
Expand All @@ -62,7 +62,7 @@ func NewNamed(name string) (NsHandle, error) {

namedPath := path.Join(bindMountPath, name)

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

var pidFile string
if cgroupVer == 1 {
switch cgroupVer {
case 1:
pidFile = "tasks"
} else if cgroupVer == 2 {
case 2:
pidFile = "cgroup.procs"
} else {
default:
return -1, fmt.Errorf("Invalid cgroup version '%d'", cgroupVer)
}

Expand Down
8 changes: 2 additions & 6 deletions netns_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@

package netns

import (
"errors"
)
import "errors"

var (
ErrNotImplemented = errors.New("not implemented")
)
var ErrNotImplemented = errors.New("not implemented")

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