From 4bcadeccec228d05242dcc73aa9b1cce918a5830 Mon Sep 17 00:00:00 2001 From: SSushmitha8 Date: Thu, 17 Oct 2024 15:00:54 -0700 Subject: [PATCH] Run gofumpt --- xtime/time.go | 6 ++---- xtime/time_unmarshal_test.go | 17 ++++++----------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/xtime/time.go b/xtime/time.go index 46c9123..309c6cf 100644 --- a/xtime/time.go +++ b/xtime/time.go @@ -77,7 +77,6 @@ func (d *Duration) UnmarshalYAML(value *yaml.Node) error { return nil } return fmt.Errorf("unable to unmarshal %s", value.Tag) - } // UnmarshalJSON implements json.Unmarshaler @@ -125,7 +124,6 @@ func (d Duration) Msgsize() int { } // Implements yaml.Marshaler - Converts duration to human-readable format (e.g., "2h", "30m") - func (d Duration) MarshalYAML() (interface{}, error) { - return time.Duration(d).String(), nil +func (d Duration) MarshalYAML() (interface{}, error) { + return time.Duration(d).String(), nil } - diff --git a/xtime/time_unmarshal_test.go b/xtime/time_unmarshal_test.go index 57b082d..6fd50d1 100644 --- a/xtime/time_unmarshal_test.go +++ b/xtime/time_unmarshal_test.go @@ -57,7 +57,6 @@ dur: 1w1s`) if err := json.Unmarshal(jsonData, &jsonTest); err != nil { t.Fatal(err) } - } func TestMarshalUnmarshalDuration(t *testing.T) { @@ -113,32 +112,28 @@ func TestEncodeDecodeDuration(t *testing.T) { } } - func TestDuration_Marshal(t *testing.T) { type testDuration struct { - A Duration `json:"a" yaml:"a"` - Dur Duration `json:"dur" yaml:"dur"` + A Duration `json:"a" yaml:"a"` + Dur Duration `json:"dur" yaml:"dur"` DurationPointer *Duration `json:"durationPointer,omitempty" yaml:"durationPointer,omitempty"` } - d1 := Duration(time.Second) - d2 := Duration(0) - d3 := Duration(time.Hour*24*7 + time.Second) + d2 := Duration(0) + d3 := Duration(time.Hour*24*7 + time.Second) testData := testDuration{ - A: d1, - Dur: d2, + A: d1, + Dur: d2, DurationPointer: &d3, } - yamlData, err := yaml.Marshal(&testData) if err != nil { t.Fatalf("Failed to marshal YAML: %v", err) } - expected := `a: 1s dur: 0s durationPointer: 168h0m1s