Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit 4fc5ba5

Browse files
committed
Enforce time.Local = time.UTC in all binary entrypoints
1 parent ab1caf9 commit 4fc5ba5

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all setup lint build test image-build image-push
1+
.PHONY: all setup lint lint-timezone build test image-build image-push
22

33
TEST_TIMEOUT := 10s
44
SHELL := /bin/bash
@@ -22,13 +22,25 @@ bin/gofumpt: bin
2222
build: cmd/main.go
2323
CGO_ENABLED=0 go build -ldflags="-X github.com/duneanalytics/blockchain-ingester/client/duneapi.commitHash=$(shell git rev-parse --short HEAD)" -o indexer cmd/main.go
2424

25-
lint: bin/golangci-lint bin/gofumpt
25+
lint: bin/golangci-lint bin/gofumpt lint-timezone
2626
go fmt ./...
2727
go vet ./...
2828
bin/golangci-lint -c .golangci.yml run ./...
2929
bin/gofumpt -l -e -d ./
3030
go mod tidy
3131

32+
# All binary entrypoints must set time.Local = time.UTC in init() to ensure
33+
# time.Now() always returns UTC.
34+
lint-timezone:
35+
@fail=0; \
36+
for f in $$(find . -name main.go -path '*/cmd/*/main.go'); do \
37+
if ! grep -q 'time\.Local = time\.UTC' "$$f"; then \
38+
echo "ERROR: $$f missing 'time.Local = time.UTC' in init()"; \
39+
fail=1; \
40+
fi; \
41+
done; \
42+
if [ "$$fail" -eq 1 ]; then exit 1; fi
43+
3244
test:
3345
go mod tidy
3446
CGO_ENABLED=1 go test -timeout=$(TEST_TIMEOUT) -race -bench=. -benchmem -cover ./...

0 commit comments

Comments
 (0)