Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

New linter for detecting bad usage of time.Time #383

Closed
richardartoul opened this issue Nov 6, 2017 · 4 comments
Closed

New linter for detecting bad usage of time.Time #383

richardartoul opened this issue Nov 6, 2017 · 4 comments

Comments

@richardartoul
Copy link

Hello,

My team ran into this issue recently upgrading to Go 1.9. We were using a lot of maps where the key was either a time.Time, or contained a nested time.Time.

Due to the changes to the internal representation of time.Time in Go 1.9, this becomes very dangerous and error-prone so we wrote a linter to auto-detect it.

The linter (along with a more detailed explanation) is here: https://github.com/m3db/build-tools/tree/master/linters/maptime

Is there any interest in mentioning this linter in the README? I could make a P.R

@flimzy
Copy link

flimzy commented Nov 13, 2017

broken (private?) link.

@richardartoul
Copy link
Author

Sorry we renamed it (promise we won't do that again) because we expanded its functionality to also detect stuff like time.Time{} == time.Time{}

This link should work: https://github.com/m3db/build-tools/tree/master/linters/badtime

@richardartoul
Copy link
Author

We ran it on our own codebases and it found a good number of real issues, as well as things that could have easily become bugs in the future

@richardartoul richardartoul changed the title New linter for detecting map[time.Time] and variants New linter for detecting bad usage of time.Time Nov 14, 2017
@ferhatelmas
Copy link

@richardartoul You might want to jump into discussion on golang/go#22977 and golang/go#22978

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants