A custom linter for golangci-lint that ensures all time.Now() calls are followed by .UTC().
This linter helps prevent timezone-related bugs by ensuring that all time.Now() calls are immediately followed by .UTC(). This is particularly useful in applications where consistent timezone handling is critical.
go install github.com/nirvana-labs/go-analyzer-utctime@latestAdd the linter to your .golangci.yml configuration:
linters:
enable:
- utctime
linters-settings:
custom:
utctime:
path: github.com/nirvana-labs/go-analyzer-utctime// Bad:
t := time.Now() // Will trigger a linter error
// Good:
t := time.Now().UTC()MIT License
Contributions are welcome! Please feel free to submit a Pull Request.