mirror of
https://github.com/vishvananda/netns
synced 2025-01-02 20:32:03 +00:00
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 <matthieu.morel35@gmail.com>
This commit is contained in:
parent
59920981a6
commit
364b2a2cb9
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user