From 8a0c3a077cb389ff8cd18fb14d43476c21acb5ce Mon Sep 17 00:00:00 2001
From: Daniel <dhaavi@users.noreply.github.com>
Date: Thu, 29 Oct 2020 13:58:33 +0100
Subject: [PATCH] Fix linter errors and update deps

---
 config/option.go                |  2 +-
 config/validate.go              |  2 +-
 database/hook.go                |  2 +-
 modules/subsystems/module.go    | 16 ++++++++--------
 modules/subsystems/registry.go  |  6 +++---
 modules/subsystems/subsystem.go |  2 +-
 runtime/module_api.go           |  4 +---
 runtime/registry.go             |  2 +-
 runtime/registry_test.go        |  6 +++---
 9 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/config/option.go b/config/option.go
index 5e7191b..0a5ac5c 100644
--- a/config/option.go
+++ b/config/option.go
@@ -177,7 +177,7 @@ type Option struct {
 	// been created.
 	Description string
 	// Help may hold a long version of the description providing
-	// assistence with the configuration option.
+	// assistance with the configuration option.
 	// Help is considered immutable after the option has
 	// been created.
 	Help string
diff --git a/config/validate.go b/config/validate.go
index 0138379..58fd319 100644
--- a/config/validate.go
+++ b/config/validate.go
@@ -45,7 +45,7 @@ func isAllowedPossibleValue(opt *Option, value interface{}) error {
 		compareAgainst := val.Value
 		valueType := reflect.TypeOf(value)
 
-		// loading int's from the configuration JSON does not perserve the correct type
+		// loading int's from the configuration JSON does not preserve the correct type
 		// as we get float64 instead. Make sure to convert them before.
 		if reflect.TypeOf(val.Value).ConvertibleTo(valueType) {
 			compareAgainst = reflect.ValueOf(val.Value).Convert(valueType).Interface()
diff --git a/database/hook.go b/database/hook.go
index f395ef0..e4a1d13 100644
--- a/database/hook.go
+++ b/database/hook.go
@@ -17,7 +17,7 @@ type Hook interface {
 	// the underlying storage. A PreGet hookd may be used to
 	// implement more advanced access control on database keys.
 	PreGet(dbKey string) error
-	// UsesPostGet should returnd true if the hook's PostGet
+	// UsesPostGet should return true if the hook's PostGet
 	// should be called after loading a database record from
 	// the underlying storage.
 	UsesPostGet() bool
diff --git a/modules/subsystems/module.go b/modules/subsystems/module.go
index 406ed53..539fe77 100644
--- a/modules/subsystems/module.go
+++ b/modules/subsystems/module.go
@@ -21,7 +21,7 @@ var (
 	printGraphFlag bool
 )
 
-// Register registeres a new subsystem. It's like Manager.Register
+// Register registers a new subsystem. It's like Manager.Register
 // but uses DefaultManager and panics on error.
 func Register(id, name, description string, module *modules.Module, configKeySpace string, option *config.Option) {
 	err := DefaultManager.Register(id, name, description, module, configKeySpace, option)
@@ -92,7 +92,7 @@ func prep() error {
 
 func start() error {
 	// Registration of subsystems is only allowed during
-	// preperation. Make sure any further call to Register()
+	// preparation. Make sure any further call to Register()
 	// panics.
 	if err := DefaultManager.Start(); err != nil {
 		return err
@@ -104,9 +104,9 @@ func start() error {
 }
 
 // PrintGraph prints the subsystem and module graph.
-func (reg *Manager) PrintGraph() {
-	reg.l.RLock()
-	defer reg.l.RUnlock()
+func (mng *Manager) PrintGraph() {
+	mng.l.RLock()
+	defer mng.l.RUnlock()
 
 	fmt.Println("subsystems dependency graph:")
 
@@ -114,17 +114,17 @@ func (reg *Manager) PrintGraph() {
 	module.Disable()
 
 	// mark roots
-	for _, sub := range reg.subsys {
+	for _, sub := range mng.subsys {
 		sub.module.Enable() // mark as tree root
 	}
 
-	for _, sub := range reg.subsys {
+	for _, sub := range mng.subsys {
 		printModuleGraph("", sub.module, true)
 	}
 
 	fmt.Println("\nsubsystem module groups:")
 	_ = start() // no errors for what we need here
-	for _, sub := range reg.subsys {
+	for _, sub := range mng.subsys {
 		fmt.Printf("├── %s\n", sub.Name)
 		for _, mod := range sub.Modules[1:] {
 			fmt.Printf("│   ├── %s\n", mod.Name)
diff --git a/modules/subsystems/registry.go b/modules/subsystems/registry.go
index 06aa040..1da1587 100644
--- a/modules/subsystems/registry.go
+++ b/modules/subsystems/registry.go
@@ -36,7 +36,7 @@ type Manager struct {
 	runtime        *runtime.Registry
 }
 
-// NewManager returns a new subsystem manager that registeres
+// NewManager returns a new subsystem manager that registers
 // itself at rtReg.
 func NewManager(rtReg *runtime.Registry) (*Manager, error) {
 	mng := &Manager{
@@ -71,7 +71,7 @@ func (mng *Manager) Start() error {
 	}
 
 	// aggregate all modules dependencies (and the subsystem module itself)
-	// into the Modules slice. Configuration options form dependened modules
+	// into the Modules slice. Configuration options form dependent modules
 	// will be marked using config.SubsystemAnnotation if not already set.
 	for _, sub := range mng.subsys {
 		sub.Modules = append(sub.Modules, statusFromModule(sub.module))
@@ -118,7 +118,7 @@ func (mng *Manager) Get(keyOrPrefix string) ([]record.Record, error) {
 	return records, nil
 }
 
-// Register registeres a new subsystem. The given option must be a bool option.
+// Register registers a new subsystem. The given option must be a bool option.
 // Should be called in init() directly after the modules.Register() function.
 // The config option must not yet be registered and will be registered for
 // you. Pass a nil option to force enable.
diff --git a/modules/subsystems/subsystem.go b/modules/subsystems/subsystem.go
index f317c6b..ccfb320 100644
--- a/modules/subsystems/subsystem.go
+++ b/modules/subsystems/subsystem.go
@@ -28,7 +28,7 @@ type Subsystem struct { //nolint:maligned // not worth the effort
 	// FailureStatus is the worst failure status that is currently
 	// set in one of the subsystem's dependencies.
 	FailureStatus uint8
-	// ToggleOptionKey holds the key of the configuraiton option
+	// ToggleOptionKey holds the key of the configuration option
 	// that is used to completely enable or disable this subsystem.
 	ToggleOptionKey string
 	// ExpertiseLevel defines the complexity of the subsystem and is
diff --git a/runtime/module_api.go b/runtime/module_api.go
index 58516a6..2316c91 100644
--- a/runtime/module_api.go
+++ b/runtime/module_api.go
@@ -9,12 +9,10 @@ var (
 	// DefaultRegistry is the default registry
 	// that is used by the module-level API.
 	DefaultRegistry = NewRegistry()
-
-	module *modules.Module
 )
 
 func init() {
-	module = modules.Register("runtime", nil, startModule, nil, "database")
+	modules.Register("runtime", nil, startModule, nil, "database")
 }
 
 func startModule() error {
diff --git a/runtime/registry.go b/runtime/registry.go
index fc683ca..7c3404b 100644
--- a/runtime/registry.go
+++ b/runtime/registry.go
@@ -36,7 +36,7 @@ var (
 // package but may consider creating a dedicated
 // runtime registry on their own. Registry uses
 // a radix tree for value providers and their
-// choosen database key/prefix.
+// chosen database key/prefix.
 type Registry struct {
 	l            sync.RWMutex
 	providers    *radix.Tree
diff --git a/runtime/registry_test.go b/runtime/registry_test.go
index 458a7fb..61343da 100644
--- a/runtime/registry_test.go
+++ b/runtime/registry_test.go
@@ -43,7 +43,7 @@ func getTestRegistry(t *testing.T) *Registry {
 	r := NewRegistry()
 
 	providers := []testProvider{
-		testProvider{
+		{
 			k: "p1/",
 			r: []record.Record{
 				makeTestRecord("p1/f1/v1", "p1.1"),
@@ -51,7 +51,7 @@ func getTestRegistry(t *testing.T) *Registry {
 				makeTestRecord("p1/v3", "p1.3"),
 			},
 		},
-		testProvider{
+		{
 			k: "p2/f1",
 			r: []record.Record{
 				makeTestRecord("p2/f1/v1", "p2.1"),
@@ -104,7 +104,7 @@ func TestRegistryQuery(t *testing.T) {
 	iter, err := reg.Query(q, true, true)
 	require.NoError(t, err)
 	require.NotNil(t, iter)
-	var records []record.Record
+	var records []record.Record //nolint:prealloc
 	for r := range iter.Next {
 		records = append(records, r)
 	}