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
Currently the compiler will throw an error if the return value of append is not used, but it does not error or even warn if the return value of time.AppendFormat is not used, even though AppendFormat has the same semantics as append.
If someone calls AppendFormat without using the return value, that is always an error, because it does nothing.
I looked for linters that would catch this issue and could not find any.
EDIT: I tried to add it to go vetunusedresult but I couldn't get it to work...is it that unusedresult still only works for pure functions as stated in #14972 ?
The text was updated successfully, but these errors were encountered:
It seems reasonable to me to include time.AppendFormat in unusedresult's list of functions to warn on: funcs. The function does seem directly analogous to append. This function could be called just for a side-effect to write into a slice with sufficient capacity (just like append), in which case we are requesting users write _ = time.AppendFormat(b, ...) (again just like append).
I think it is unlikely adding time.AppendFormat to the list would cause a noticeable performance problem. This covers most of the frequency concern (README).
Currently the compiler will throw an error if the return value of
append
is not used, but it does not error or even warn if the return value oftime.AppendFormat
is not used, even thoughAppendFormat
has the same semantics asappend
.https://go.dev/play/p/IpxJrcX3FkT
If someone calls AppendFormat without using the return value, that is always an error, because it does nothing.
I looked for linters that would catch this issue and could not find any.
EDIT: I tried to add it to
go vet
unusedresult
but I couldn't get it to work...is it thatunusedresult
still only works for pure functions as stated in #14972 ?The text was updated successfully, but these errors were encountered: