统一代码风格

This commit is contained in:
gouguoyin 2021-04-06 18:04:10 +08:00
parent 054dda855d
commit f0248f3a7b
4 changed files with 2 additions and 7 deletions

View File

@ -136,7 +136,7 @@ type Carbon struct {
Error error
}
// String 实现 String 接口
// String 实现 Stringer 接口
func (c Carbon) String() string {
if c.IsZero() {
return ""
@ -167,7 +167,7 @@ func Now() Carbon {
// Tomorrow 明天
func (c Carbon) Tomorrow() Carbon {
if c.Time.IsZero() {
if c.IsZero() {
c.Time = time.Now().AddDate(0, 0, 1)
} else {
c.Time = c.Time.AddDate(0, 0, 1)

View File

@ -175,7 +175,6 @@ func (c Carbon) Compare(operator string, t Carbon) bool {
case "<=":
return c.Lte(t)
}
return false
}

View File

@ -183,9 +183,7 @@ func (c Carbon) DiffForHumans(arg ...Carbon) string {
diff = 0
return c.Lang.translate(unit, diff)
}
translation := c.Lang.translate(unit, diff)
if c.Lt(end) && len(arg) == 0 {
return strings.Replace(c.Lang.resources["ago"], "%s", translation, 1)
}
@ -198,6 +196,5 @@ func (c Carbon) DiffForHumans(arg ...Carbon) string {
if c.Gt(end) && len(arg) > 0 {
return strings.Replace(c.Lang.resources["after"], "%s", translation, 1)
}
return translation
}

View File

@ -64,7 +64,6 @@ func (lang *Language) SetResources(resources map[string]string) {
lang.resources = resources
return
}
for k, v := range resources {
if _, ok := lang.resources[k]; ok {
lang.resources[k] = v