Fix tests and linters
This commit is contained in:
@@ -3,14 +3,12 @@ package base
|
||||
import (
|
||||
"github.com/safing/portbase/database"
|
||||
|
||||
// database module
|
||||
// Dependencies.
|
||||
_ "github.com/safing/portbase/database/dbmodule"
|
||||
|
||||
// module dependencies
|
||||
_ "github.com/safing/portbase/database/storage/bbolt"
|
||||
)
|
||||
|
||||
// Default Values (changeable for testing)
|
||||
// Default Values (changeable for testing).
|
||||
var (
|
||||
DefaultDatabaseStorageType = "bbolt"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/safing/portbase/modules"
|
||||
)
|
||||
|
||||
// Default Values (changeable for testing)
|
||||
// Default Values (changeable for testing).
|
||||
var (
|
||||
DefaultAPIListenAddress = "127.0.0.1:817"
|
||||
|
||||
@@ -56,7 +56,7 @@ func globalPrep() error {
|
||||
}
|
||||
|
||||
// initialize structure
|
||||
err := dataroot.Initialize(dataDir, 0755)
|
||||
err := dataroot.Initialize(dataDir, 0o0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
_ "github.com/safing/portbase/config"
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/metrics"
|
||||
"github.com/safing/portbase/modules"
|
||||
|
||||
// module dependencies
|
||||
_ "github.com/safing/portbase/config"
|
||||
_ "github.com/safing/portbase/metrics"
|
||||
_ "github.com/safing/portbase/rng"
|
||||
)
|
||||
|
||||
var (
|
||||
module *modules.Module
|
||||
)
|
||||
var module *modules.Module
|
||||
|
||||
func init() {
|
||||
module = modules.Register("base", nil, start, nil, "database", "config", "rng", "metrics")
|
||||
|
||||
@@ -8,9 +8,7 @@ import (
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
var (
|
||||
cpuProfile string
|
||||
)
|
||||
var cpuProfile string
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&cpuProfile, "cpuprofile", "", "write cpu profile to `file`")
|
||||
@@ -25,10 +23,10 @@ func startProfiling() {
|
||||
func cpuProfiler(ctx context.Context) error {
|
||||
f, err := os.Create(cpuProfile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create CPU profile: %s", err)
|
||||
return fmt.Errorf("could not create CPU profile: %w", err)
|
||||
}
|
||||
if err := pprof.StartCPUProfile(f); err != nil {
|
||||
return fmt.Errorf("could not start CPU profile: %s", err)
|
||||
return fmt.Errorf("could not start CPU profile: %w", err)
|
||||
}
|
||||
|
||||
// wait for shutdown
|
||||
@@ -37,7 +35,7 @@ func cpuProfiler(ctx context.Context) error {
|
||||
pprof.StopCPUProfile()
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to close CPU profile file: %s", err)
|
||||
return fmt.Errorf("failed to close CPU profile file: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@ import (
|
||||
|
||||
"github.com/safing/portbase/modules"
|
||||
"github.com/safing/portbase/modules/subsystems"
|
||||
"github.com/safing/portmaster/updates"
|
||||
|
||||
// module dependencies
|
||||
_ "github.com/safing/portmaster/netenv"
|
||||
_ "github.com/safing/portmaster/status"
|
||||
_ "github.com/safing/portmaster/ui"
|
||||
"github.com/safing/portmaster/updates"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -65,7 +63,7 @@ func prep() error {
|
||||
|
||||
func start() error {
|
||||
if err := startPlatformSpecific(); err != nil {
|
||||
return fmt.Errorf("failed to start plattform-specific components: %s", err)
|
||||
return fmt.Errorf("failed to start plattform-specific components: %w", err)
|
||||
}
|
||||
|
||||
registerLogCleaner()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build !windows
|
||||
// go:build !windows
|
||||
|
||||
package core
|
||||
|
||||
|
||||
@@ -24,18 +24,14 @@ import (
|
||||
"runtime/pprof"
|
||||
"testing"
|
||||
|
||||
_ "github.com/safing/portbase/database/storage/hashmap"
|
||||
"github.com/safing/portbase/dataroot"
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/modules"
|
||||
"github.com/safing/portmaster/core/base"
|
||||
|
||||
// module dependencies
|
||||
_ "github.com/safing/portbase/database/storage/hashmap"
|
||||
)
|
||||
|
||||
var (
|
||||
printStackOnExit bool
|
||||
)
|
||||
var printStackOnExit bool
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&printStackOnExit, "print-stack-on-exit", false, "prints the stack before of shutting down")
|
||||
@@ -73,7 +69,7 @@ func TestMainWithHooks(m *testing.M, module *modules.Module, afterStartFn, befor
|
||||
// tmp dir for data root (db & config)
|
||||
tmpDir := filepath.Join(os.TempDir(), "portmaster-testing")
|
||||
// initialize data dir
|
||||
err := dataroot.Initialize(tmpDir, 0755)
|
||||
err := dataroot.Initialize(tmpDir, 0o0755)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to initialize data root: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user