Browse Source

libnetwork/options: remove unused NewGeneric, and use map[string]any

Remove the NewGeneric utility as it was not used anywhere, except for
in tests.

Also "modernize" the type, and use `any` instead of `interface{}`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 years ago
parent
commit
948f55d0b7
2 changed files with 11 additions and 14 deletions
  1. 1 6
      libnetwork/options/options.go
  2. 10 8
      libnetwork/options/options_test.go

+ 1 - 6
libnetwork/options/options.go

@@ -42,12 +42,7 @@ func (e TypeMismatchError) Error() string {
 }
 
 // Generic is a basic type to store arbitrary settings.
-type Generic map[string]interface{}
-
-// NewGeneric returns a new Generic instance.
-func NewGeneric() Generic {
-	return make(Generic)
-}
+type Generic map[string]any
 
 // GenerateFromModel takes the generic options, and tries to build a new
 // instance of the model's type by matching keys from the generic options to

+ 10 - 8
libnetwork/options/options_test.go

@@ -7,10 +7,11 @@ import (
 )
 
 func TestGenerate(t *testing.T) {
-	gen := NewGeneric()
-	gen["Int"] = 1
-	gen["Rune"] = 'b'
-	gen["Float64"] = 2.0
+	gen := Generic{
+		"Int":     1,
+		"Rune":    'b',
+		"Float64": 2.0,
+	}
 
 	type Model struct {
 		Int     int
@@ -39,10 +40,11 @@ func TestGenerate(t *testing.T) {
 }
 
 func TestGeneratePtr(t *testing.T) {
-	gen := NewGeneric()
-	gen["Int"] = 1
-	gen["Rune"] = 'b'
-	gen["Float64"] = 2.0
+	gen := Generic{
+		"Int":     1,
+		"Rune":    'b',
+		"Float64": 2.0,
+	}
 
 	type Model struct {
 		Int     int