mirror of https://github.com/vishvananda/netns
enable gocritic, gosec, gosimple, govet unconvert, unparam, unused and whitespace linters (#72)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
364b2a2cb9
commit
df76f818b3
|
@ -2,10 +2,18 @@ linters:
|
||||||
enable:
|
enable:
|
||||||
- errcheck
|
- errcheck
|
||||||
- errorlint
|
- errorlint
|
||||||
|
- gocritic
|
||||||
|
- gosec
|
||||||
|
- gosimple
|
||||||
|
- govet
|
||||||
- gci
|
- gci
|
||||||
- misspell
|
- misspell
|
||||||
- nonamedreturns
|
- nonamedreturns
|
||||||
- staticcheck
|
- staticcheck
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
- whitespace
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gci:
|
gci:
|
||||||
|
|
|
@ -49,7 +49,7 @@ func New() (NsHandle, error) {
|
||||||
// and returns a handle to it
|
// and returns a handle to it
|
||||||
func NewNamed(name string) (NsHandle, error) {
|
func NewNamed(name string) (NsHandle, error) {
|
||||||
if _, err := os.Stat(bindMountPath); os.IsNotExist(err) {
|
if _, err := os.Stat(bindMountPath); os.IsNotExist(err) {
|
||||||
err = os.MkdirAll(bindMountPath, 0755)
|
err = os.MkdirAll(bindMountPath, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return None(), err
|
return None(), err
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func NewNamed(name string) (NsHandle, error) {
|
||||||
|
|
||||||
namedPath := path.Join(bindMountPath, name)
|
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 {
|
if err != nil {
|
||||||
newNs.Close()
|
newNs.Close()
|
||||||
return None(), err
|
return None(), err
|
||||||
|
@ -217,11 +217,12 @@ func getPidForContainer(id string) (int, error) {
|
||||||
id += "*"
|
id += "*"
|
||||||
|
|
||||||
var pidFile string
|
var pidFile string
|
||||||
if cgroupVer == 1 {
|
switch cgroupVer {
|
||||||
|
case 1:
|
||||||
pidFile = "tasks"
|
pidFile = "tasks"
|
||||||
} else if cgroupVer == 2 {
|
case 2:
|
||||||
pidFile = "cgroup.procs"
|
pidFile = "cgroup.procs"
|
||||||
} else {
|
default:
|
||||||
return -1, fmt.Errorf("Invalid cgroup version '%d'", cgroupVer)
|
return -1, fmt.Errorf("Invalid cgroup version '%d'", cgroupVer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,9 @@
|
||||||
|
|
||||||
package netns
|
package netns
|
||||||
|
|
||||||
import (
|
import "errors"
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var ErrNotImplemented = errors.New("not implemented")
|
||||||
ErrNotImplemented = errors.New("not implemented")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Setns sets namespace using golang.org/x/sys/unix.Setns on Linux. It
|
// Setns sets namespace using golang.org/x/sys/unix.Setns on Linux. It
|
||||||
// is not implemented on other platforms.
|
// is not implemented on other platforms.
|
||||||
|
|
Loading…
Reference in New Issue