Fix tests and linters

This commit is contained in:
Daniel
2022-02-02 12:48:42 +01:00
parent f2fcad4d11
commit 60d8664e7b
171 changed files with 944 additions and 874 deletions

View File

@@ -1,4 +1,4 @@
// +build linux
// go:build linux
package proc
@@ -7,9 +7,8 @@ import (
"os"
"time"
"github.com/safing/portmaster/network/socket"
"github.com/safing/portbase/log"
"github.com/safing/portmaster/network/socket"
)
var (
@@ -128,7 +127,10 @@ func readDirNames(dir string) (names []string) {
}
return
}
defer file.Close()
defer func() {
_ = file.Close()
}()
names, err = file.Readdirnames(0)
if err != nil {
log.Warningf("proc: could not get entries from directory %s: %s", dir, err)

View File

@@ -1,4 +1,4 @@
// +build linux
// go:build linux
package proc

View File

@@ -1,4 +1,4 @@
// +build linux
// go:build linux
package proc
@@ -12,9 +12,8 @@ import (
"strings"
"unicode"
"github.com/safing/portmaster/network/socket"
"github.com/safing/portbase/log"
"github.com/safing/portmaster/network/socket"
)
/*
@@ -85,7 +84,6 @@ const (
)
func getTableFromSource(stack uint8, procFile string) (connections []*socket.ConnectionInfo, binds []*socket.BindInfo, err error) {
var ipConverter func(string) net.IP
switch stack {
case TCP4, UDP4:
@@ -101,7 +99,9 @@ func getTableFromSource(stack uint8, procFile string) (connections []*socket.Con
if err != nil {
return nil, nil, err
}
defer socketData.Close()
defer func() {
_ = socketData.Close()
}()
// file scanner
scanner := bufio.NewScanner(socketData)

View File

@@ -1,4 +1,4 @@
// +build linux
// go:build linux
package proc
@@ -8,6 +8,8 @@ import (
)
func TestSockets(t *testing.T) {
t.Parallel()
connections, listeners, err := GetTCP4Table()
if err != nil {
t.Fatal(err)