Skip to content

Commit

Permalink
c.Error != nil || c.IsZero() -> c.IsInvalid()
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Nov 29, 2024
1 parent 49c1266 commit 4341045
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion outputer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion outputer_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4341045

Please sign in to comment.