diff --git a/core/core.go b/core/core.go index 5dd827ad..8e3345ac 100644 --- a/core/core.go +++ b/core/core.go @@ -1,11 +1,19 @@ package core -import "github.com/safing/portbase/modules" +import ( + "fmt" + + "github.com/safing/portbase/modules" +) var ( coreModule = modules.Register("core", nil, startCore, nil, "base", "database", "config", "api", "random") ) func startCore() error { + if err := startPlatformSpecific(); err != nil { + return fmt.Errorf("failed to start plattform-specific stuff: %s", err) + } + return registerDatabases() } diff --git a/core/os_default.go b/core/os_default.go new file mode 100644 index 00000000..459e41a2 --- /dev/null +++ b/core/os_default.go @@ -0,0 +1,8 @@ +// +build !windows + +package core + +// only return on Fatal error! +func startPlatformSpecific() error { + return nil +} diff --git a/core/os_windows.go b/core/os_windows.go new file mode 100644 index 00000000..41f1f594 --- /dev/null +++ b/core/os_windows.go @@ -0,0 +1,16 @@ +package core + +import ( + "github.com/safing/portbase/log" + "github.com/safing/portbase/utils/osdetail" +) + +// only return on Fatal error! +func startPlatformSpecific() error { + // We can't catch errors when calling WindowsNTVersion() in logging, so we call the function here, just to catch possible errors + if _, err := osdetail.WindowsNTVersion(); err != nil { + log.Errorf("failed to obtain WindowsNTVersion: %s", err) + } + + return nil +}