You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for your great work. A common error in our code base that happens over and over again is something like that:
t := time.Now()
t.Add(1 * time.Hour)
fmt.Println(t)
Since time.Time is a "value type", Add() does not modify the current value and returns a new time object, which is unused in the code above. Calling time.Add() without using the return value is always an error.
There are probably lots of similar functions in the standard library. The same check might be used to for time.In, strings.ToLower and strings.ToUpper as well.
Are you interested in a check like that, how should it be called and should I try to prepare a MR for it?
The text was updated successfully, but these errors were encountered:
Hi, thanks for your great work. A common error in our code base that happens over and over again is something like that:
Since
time.Time
is a "value type",Add()
does not modify the current value and returns a new time object, which is unused in the code above. Callingtime.Add()
without using the return value is always an error.There are probably lots of similar functions in the standard library. The same check might be used to for
time.In
,strings.ToLower
andstrings.ToUpper
as well.Are you interested in a check like that, how should it be called and should I try to prepare a MR for it?
The text was updated successfully, but these errors were encountered: