-
Notifications
You must be signed in to change notification settings - Fork 18k
time: document that Local must not be modified #34814
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
Comments
We can't provide the source code but a compiled |
After figuring out how to bring back the main routine stack, the write occurs in an init function that sets the time.Local to the current location. |
@urandom, is anything in your program mutating the |
@bcmills |
Yeah, don't do that. That's an application error, not a bug in the standard library. As you have seen, packages can (and do) assume that it is safe to spawn goroutines that call If you need to customize a program's notion of “local time”, that's what the Lines 29 to 32 in fb9af84
|
Change https://golang.org/cl/200457 mentions this issue: |
@bcmills, while the doc change would be useful, actually mentioning the TZ env anywhere in the time package would have a greater effect. As it currently stands, even if you mention that one should not modify Local, a user will have no idea what to do to actually change the local TZ. |
Sure, it seems reasonable to mention the use of |
Hi I'm submitting a CL to improve the documentation as is requested in the issue. However, I'm wondering if I know, right now it would break the compatibility rule. Nevertheless I'd like to raise this idea. Maybe create another function and recommend to use it instead of |
Change https://golang.org/cl/200858 mentions this issue: |
The existing documentation does not explicitly state clients should not modify their values. Fixes golang#34814 Change-Id: I9b8390545c1dd43dc774b5f7b294257ba4e41ad5
I agree that it would be nice if there were a way to prevent these variables from being changed. But language style is generally to use variables rather than functions where appropriate. Given that we already have variables, and they do work, I don't see a strong justification for changing to functions. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It's not reproducible every time.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Seems to be reproducible with MAX_PROCS > 2
What did you expect to see?
Nothing
What did you see instead?
or
and
The text was updated successfully, but these errors were encountered: