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

@@ -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"
)

View File

@@ -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
}

View File

@@ -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")

View File

@@ -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
}