From 1150734ab01f817b3341fa590c22f9c241cee842 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sun, 1 Sep 2024 21:14:46 +0200 Subject: [PATCH] Remove redundant Get() method The Get() method was simply an alias for the Value() method and did not add any functionality. This simplification makes the code cleaner and reduces unnecessary duplication, improving maintainability. --- niljson.go | 5 ----- niljson_test.go | 36 ------------------------------------ 2 files changed, 41 deletions(-) diff --git a/niljson.go b/niljson.go index ccd795a..2f01999 100644 --- a/niljson.go +++ b/niljson.go @@ -19,11 +19,6 @@ func (v *Variable[T]) Value() T { return v.value } -// Get is an alias method for Value() -func (v *Variable[T]) Get() T { - return v.Value() -} - // NotNil returns true when a Variable is not nil func (v *Variable[T]) NotNil() bool { return v.notNil diff --git a/niljson_test.go b/niljson_test.go index 986e2fa..458dd34 100644 --- a/niljson_test.go +++ b/niljson_test.go @@ -49,9 +49,6 @@ func TestVariable_UnmarshalJSON_Boolean(t *testing.T) { if !jt.Value.Value() { t.Errorf("expected value to be true, got %t", jt.Value.Value()) } - if !jt.Value.Get() { - t.Errorf("expected value to be true, got %t", jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -79,9 +76,6 @@ func TestVariable_UnmarshalJSON_ByteSlice(t *testing.T) { if !bytes.Equal(jt.Value.Value(), []byte("bytes")) { t.Errorf("expected value to be %q, got %q", "bytes", jt.Value.Value()) } - if !bytes.Equal(jt.Value.Get(), []byte("bytes")) { - t.Errorf("expected value to be %q, got %q", "bytes", jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -110,9 +104,6 @@ func TestVariable_UnmarshalJSON_Float32(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %f, got %f", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %f, got %f", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -141,9 +132,6 @@ func TestVariable_UnmarshalJSON_Float64(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %f, got %f", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %f, got %f", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -172,9 +160,6 @@ func TestVariable_UnmarshalJSON_Int(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -203,9 +188,6 @@ func TestVariable_UnmarshalJSON_Int64(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -234,9 +216,6 @@ func TestVariable_UnmarshalJSON_String(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %s, got %s", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %s, got %s", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -265,9 +244,6 @@ func TestVariable_UnmarshalJSON_UInt(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -296,9 +272,6 @@ func TestVariable_UnmarshalJSON_UInt8(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -327,9 +300,6 @@ func TestVariable_UnmarshalJSON_UInt16(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -358,9 +328,6 @@ func TestVariable_UnmarshalJSON_UInt32(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() { @@ -389,9 +356,6 @@ func TestVariable_UnmarshalJSON_UInt64(t *testing.T) { if jt.Value.Value() != expected { t.Errorf("expected value to be %d, got %d", expected, jt.Value.Value()) } - if jt.Value.Get() != expected { - t.Errorf("expected value to be %d, got %d", expected, jt.Value.Get()) - } jt.Value.Reset() if jt.Value.NotNil() {