1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-25 22:12:38 +02:00
Files
revive/test/time_date_test.go
ccoVeille 3cac850cb6 feature: add rule time-date to check for time.Date usage (#1327)
This commit introduces a new rule to check for the usage of time.Date

The rule is added to report the usage of time.Date with non-decimal literals

Here the leading zeros that seems OK, forces the value to be octal literals.
time.Date(2023, 01, 02, 03, 04, 05, 06, time.UTC)

gofumpt formats the code like this when it encounters leading zeroes.
time.Date(2023, 0o1, 0o2, 0o3, 0o4, 0o5, 0o6, time.UTC)

The rule reports anything that is not a decimal literal.
2025-05-22 21:44:04 +02:00

12 lines
172 B
Go

package test
import (
"testing"
"github.com/mgechev/revive/rule"
)
func TestTimeDate(t *testing.T) {
testRule(t, "time_date_decimal_literal", &rule.TimeDateRule{})
}