Skip to content

duration-multiplied-by-duration

Detect multiplication of two time.Duration values.

Updated View as Markdown

Default severity: warning

time.Duration is a scalar count of nanoseconds. Multiplying two duration values produces squared time units, which is almost never meaningful. This often happens when a value that was expected to be a unitless count has already been converted to a duration.

Bad

delay := duration * time.Second

Good

delay := time.Duration(count) * time.Second
Navigation

Type to search…

↑↓ navigate↵ selectEsc close