From 434104503b49b5da0a32af2e2c3c5606995af63a Mon Sep 17 00:00:00 2001 From: gouguoyin <245629560@qq.com> Date: Fri, 29 Nov 2024 12:03:20 +0800 Subject: [PATCH] c.Error != nil || c.IsZero() -> c.IsInvalid() --- outputer.go | 2 +- outputer_unit_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/outputer.go b/outputer.go index 3162825e..eebce8ef 100644 --- a/outputer.go +++ b/outputer.go @@ -17,7 +17,7 @@ func (c Carbon) String() string { // GoString implements fmt.GoStringer and formats c to be printed in Go source code. // 实现 fmt.GoStringer 接口,并格式化 c 以在 Go 源代码中打印 func (c Carbon) GoString() string { - if c.Error != nil || c.IsZero() { + if c.IsInvalid() { return "" } return c.StdTime().GoString() diff --git a/outputer_unit_test.go b/outputer_unit_test.go index 5241845e..532aa289 100644 --- a/outputer_unit_test.go +++ b/outputer_unit_test.go @@ -55,7 +55,7 @@ func TestCarbon_GoString(t *testing.T) { { name: "case2", actual: Parse("0000-01-01 13:14:15", UTC).GoString(), - want: "time.Date(0, time.January, 1, 13, 14, 15, 0, time.UTC)", + want: "", }, { name: "case3",