dominikh / go-tools

Staticcheck - The advanced Go linter
https://staticcheck.dev
MIT License
6.22k stars 377 forks source link

simple: suggest time.Time.After, time.Time.Before #1595

Open johanbrandhorst opened 3 months ago

johanbrandhorst commented 3 months ago

Examples:

  1. Suggest rewrite of
    if x.Sub(y) > 0

    to

    if x.After(y)
  2. Suggest rewrite of
    if x.Sub(y) < 0

    to

    if x.Before(y)

Could also suggest !x.After instead of x.Sub(y) <= 0 and vice versa, but it's maybe a little more nuanced.