Skip to content

fix: embed IANA timezone database to fix startup failure on Windows#1434

Open
octo-patch wants to merge 1 commit intoWei-Shaw:mainfrom
octo-patch:fix/issue-1398-embed-tzdata
Open

fix: embed IANA timezone database to fix startup failure on Windows#1434
octo-patch wants to merge 1 commit intoWei-Shaw:mainfrom
octo-patch:fix/issue-1398-embed-tzdata

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #1398

Problem

On platforms without a system-level timezone database (notably Windows), time.LoadLocation() fails with unknown time zone Asia/Shanghai, causing the server to exit at startup:

Failed to initialize application: invalid timezone "Asia/Shanghai": unknown time zone Asia/Shanghai

Go's time.LoadLocation relies on the OS timezone data (/usr/share/zoneinfo on Linux/macOS), which is not available on Windows.

Solution

Add a blank import of time/tzdata in backend/cmd/server/main.go. This embeds the complete IANA timezone database directly into the compiled binary (~450 KB overhead), making all time.LoadLocation calls work on every platform without requiring OS timezone data.

import _ "time/tzdata" // embed IANA timezone database for platforms without system tzdata (e.g. Windows)

Testing

  • Root cause confirmed by tracing timezone.Init() in internal/pkg/timezone/timezone.go through internal/repository/ent.go
  • This is the standard, well-documented Go solution: https://pkg.go.dev/time/tzdata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exe直接运行配置好后登录报404

1 participant