Kaynağa Gözat

Merge pull request #45984 from thaJeztah/libnetwork_cleanup_options

libnetwork/options: remove unused NewGeneric, and use map[string]any
Bjorn Neergaard 2 yıl önce
ebeveyn
işleme
75d7e053dc

+ 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