-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time: add notimetzdata tag to disable tzdata embed #38679
Comments
I think this is premature. The docs for the |
The language doesn't constraints this. But only one question is why tzdata should be bundled optionally with an import? Transitive libraries can broke an environment for an app. Tags are still good. |
New tag definitions add additional complexity and require additional documentation and testing. They also require additional work by users to understand what they mean. They are a fine tool when appropriate, but I see no reason to add them because of a purely speculative problem. Also, how do you know when to use the tag? Unless you decide to use it all the time just in case, which seems unlikely for 99.9% of Go users, you'll identify the problem when you examine why your program is larger. And then you'll remove the unnecessary import, rather than using a tag. |
Agree, probably it will be same to Feel free to close this issue, thank you for fast response. I still prefer tag-only version without another ability to change global state via imports, but probably it is not so user-friendly. |
I agreed that is speculative problem. Another examples: http.DefaultClient(which is bad pattern imho), rand.globalRand(seeds). |
The tzdata package has no API so the risk of people importing it for some symbol and accidentally getting the large side effect is less than other packages that mix side effects and API. That's probably a lesson to learn. |
Sounds reasonable. Consensus is that misuse risk is minimal, so closing. |
Following #38017
Currently any transitive dependency that performs
import _ "time/tzdata"
will add 800kb to binary size, which is unfortunate and can compromise ongoing efforts to reduce binary size (e.g. https://github.com/tailscale/go by @bradfitz)I propose to add
notimetzdata
tag so we can opt-out embedded tzdata and will makeimport _ "time/tzdata"
no-op.What do you think? 🙂
The text was updated successfully, but these errors were encountered: