Repository: apigee/registry (go)

Issue:
staticcheck: ST1012 (problems with error variable names)
pkg/config/config.go:35:2: error var NoActiveConfigurationError should have name of the form ErrFoo (ST1012)
pkg/config/config.go:43:2: error var CannotDeleteActiveError should have name of the form ErrFoo (ST1012)
pkg/config/config.go:44:2: error var ReservedConfigNameError should have name of the form ErrFoo (ST1012)

Pull request description:
fix error variable names
Fixes #747

Patch:
diff --git a/cmd/registry/cmd/auth/print_token.go b/cmd/registry/cmd/auth/print_token.go
index 602c02f..ed472f4 100644
--- a/cmd/registry/cmd/auth/print_token.go
+++ b/cmd/registry/cmd/auth/print_token.go
@@ -32,7 +32,7 @@ func printTokenCommand() *cobra.Command {
 
 			_, c, err := config.ActiveRaw()
 			if err != nil {
-				if err == config.NoActiveConfigurationError {
+				if err == config.ErrNoActiveConfiguration {
 					return fmt.Errorf(`No active configuration. Use 'registry config configurations' to manage.`)
 				}
 				return err
diff --git a/cmd/registry/cmd/config/get.go b/cmd/registry/cmd/config/get.go
index 8d55ff5..459a1b4 100644
--- a/cmd/registry/cmd/config/get.go
+++ b/cmd/registry/cmd/config/get.go
@@ -31,7 +31,7 @@ func getCommand() *cobra.Command {
 			cmd.SilenceErrors = true
 			_, c, err := config.ActiveRaw()
 			if err != nil {
-				if err == config.NoActiveConfigurationError {
+				if err == config.ErrNoActiveConfiguration {
 					return fmt.Errorf(`No active configuration. Use 'registry config configurations' to manage.`)
 				}
 				return fmt.Errorf("Cannot read config: %v", err)
diff --git a/cmd/registry/cmd/config/list.go b/cmd/registry/cmd/config/list.go
index d36d79e..234ef20 100644
--- a/cmd/registry/cmd/config/list.go
+++ b/cmd/registry/cmd/config/list.go
@@ -31,7 +31,7 @@ func listCommand() *cobra.Command {
 			cmd.SilenceErrors = true
 			target, c, err := config.ActiveRaw()
 			if err != nil {
-				if err == config.NoActiveConfigurationError {
+				if err == config.ErrNoActiveConfiguration {
 					return fmt.Errorf(`No active configuration. Use 'registry config configurations' to manage.`)
 				}
 				return fmt.Errorf("Cannot read config: %v", err)
diff --git a/cmd/registry/cmd/config/set.go b/cmd/registry/cmd/config/set.go
index 560b330..bd6259c 100644
--- a/cmd/registry/cmd/config/set.go
+++ b/cmd/registry/cmd/config/set.go
@@ -39,7 +39,7 @@ func setCommand() *cobra.Command {
 			cmd.SilenceErrors = true
 			target, c, err := config.ActiveRaw()
 			if err != nil {
-				if err == config.NoActiveConfigurationError {
+				if err == config.ErrNoActiveConfiguration {
 					return fmt.Errorf(`No active configuration. Use 'registry config configurations' to manage.`)
 				}
 				return fmt.Errorf("Cannot read config: %v", err)
diff --git a/cmd/registry/cmd/config/unset.go b/cmd/registry/cmd/config/unset.go
index 49dd77a..69494ec 100644
--- a/cmd/registry/cmd/config/unset.go
+++ b/cmd/registry/cmd/config/unset.go
@@ -31,7 +31,7 @@ func unsetCommand() *cobra.Command {
 			cmd.SilenceErrors = true
 			target, c, err := config.ActiveRaw()
 			if err != nil {
-				if err == config.NoActiveConfigurationError {
+				if err == config.ErrNoActiveConfiguration {
 					return fmt.Errorf(`No active configuration. Use 'registry config configurations' to manage.`)
 				}
 				return fmt.Errorf("Cannot read config: %v", err)
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 4675be5..39d3c37 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -32,16 +32,16 @@ import (
 const ActivePointerFilename = "active_config"
 
 var (
-	NoActiveConfigurationError = fmt.Errorf("No active configuration.")
+	ErrNoActiveConfiguration = fmt.Errorf("No active configuration.")
 
 	// Flags defines Flags that may be bound to a Configuration. Use like:
 	// `cmd.PersistentFlags().AddFlagSet(connection.Flags)`
 	Flags *pflag.FlagSet = CreateFlagSet()
 
 	// Directory is $HOME/config/registry
-	Directory               string
-	CannotDeleteActiveError = fmt.Errorf("Cannot delete active configuration")
-	ReservedConfigNameError = fmt.Errorf("%q is reserved", ActivePointerFilename)
+	Directory             string
+	ErrCannotDeleteActive = fmt.Errorf("Cannot delete active configuration")
+	ErrReservedConfigName = fmt.Errorf("%q is reserved", ActivePointerFilename)
 
 	envBindings    = []string{"registry.address", "registry.insecure", "registry.token"}
 	envPrefix      = "APG"
@@ -99,7 +99,7 @@ func ValidateName(name string) error {
 		return fmt.Errorf("name cannot be empty")
 	}
 	if name == ActivePointerFilename {
-		return ReservedConfigNameError
+		return ErrReservedConfigName
 	}
 
 	if dir, _ := filepath.Split(name); dir != "" {
@@ -134,7 +134,7 @@ func ActiveRaw() (name string, c Configuration, err error) {
 		}
 	}
 	if name == "" {
-		return name, Configuration{}, NoActiveConfigurationError
+		return name, Configuration{}, ErrNoActiveConfiguration
 	}
 
 	c, err = Read(name)
@@ -252,7 +252,7 @@ func Delete(name string) error {
 		return err
 	}
 	if name == active {
-		return CannotDeleteActiveError
+		return ErrCannotDeleteActive
 	}
 
 	f := filepath.Join(Directory, name)


Test patch:
diff --git a/pkg/config/configuration_test.go b/pkg/config/configuration_test.go
index f70af9b..cc1a8b3 100644
--- a/pkg/config/configuration_test.go
+++ b/pkg/config/configuration_test.go
@@ -367,8 +367,8 @@ func TestDeleteConfig(t *testing.T) {
 	}
 
 	err = config.Delete("config1")
-	if err != config.CannotDeleteActiveError {
-		t.Errorf("expected: %v", config.CannotDeleteActiveError)
+	if err != config.ErrCannotDeleteActive {
+		t.Errorf("expected: %v", config.ErrCannotDeleteActive)
 	}
 
 	err = config.Delete("config2")
@@ -377,8 +377,8 @@ func TestDeleteConfig(t *testing.T) {
 	}
 
 	err = config.Delete(config.ActivePointerFilename)
-	if err != config.ReservedConfigNameError {
-		t.Errorf("expected error: %v", config.ReservedConfigNameError)
+	if err != config.ErrReservedConfigName {
+		t.Errorf("expected error: %v", config.ErrReservedConfigName)
 	}
 }
 
@@ -386,12 +386,12 @@ func TestWriteInvalidNames(t *testing.T) {
 	t.Cleanup(test.CleanConfigDir(t))
 
 	err := config.Configuration{}.Write(config.ActivePointerFilename)
-	if err != config.ReservedConfigNameError {
-		t.Errorf("expected error: %v", config.ReservedConfigNameError)
+	if err != config.ErrReservedConfigName {
+		t.Errorf("expected error: %v", config.ErrReservedConfigName)
 	}
 
 	err = config.Configuration{}.Write(filepath.Join("foo", "bar"))
 	if err == nil {
-		t.Errorf("expected error: %v", config.ReservedConfigNameError)
+		t.Errorf("expected error: %v", config.ErrReservedConfigName)
 	}
 }