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>
This commit is contained in:
Sebastiaan van Stijn 2023-07-16 19:17:26 +02:00
parent 37b908aa62
commit 948f55d0b7
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 11 additions and 14 deletions

View file

@ -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

View file

@ -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