Skip to content

nirvana-labs/go-analyzer-utctime

Repository files navigation

go-analyzer-utctime

A custom linter for golangci-lint that ensures all time.Now() calls are followed by .UTC().

Description

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.

Installation

go install github.com/nirvana-labs/go-analyzer-utctime@latest

Usage

Add the linter to your .golangci.yml configuration:

linters:
  enable:
    - utctime

linters-settings:
  custom:
    utctime:
      path: github.com/nirvana-labs/go-analyzer-utctime

Examples

// Bad:
t := time.Now() // Will trigger a linter error

// Good:
t := time.Now().UTC()

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Custom linter for golangci-lint to check time.Now().UTC() is being used

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •