go-playground
go-playground copied to clipboard
Display an easy-to-notice warning when code contains `time.Now()` that the values won't be as expected
Since time.Now()
will not be fixed to work as expected (see #104, #188), please consider adding an easy-to-notice warning that the code will not operate as expected?
That would keep developers from spending a lot of time trying to figure out what the hell is wrong with their code only to realize that the problem is not necessarily their code but in-fact a known-bug in how to platform diverges from expectation.
And it would be yet another benefit to using goplay.tools vs. golang.org/play.
@mikeschinkel how do you see that to be implemented?
How about something as simple as this? When the use clicks "Run" your code does a text search for time.Now()
and if found appends a warning message to the output tile like shown in this screenshot:
@mikeschinkel thank you for a report. I'll consider to add some kind of similar notification.
Btw currently I'm planning to add yaegi-based runtime so sandbox can work fully offline.
For now, I can recommend to use WebAssembly environment but it might have some I/O limitations (filesystem, networking).

Thank you for considering.
For now, I can recommend to use WebAssembly environment
Thank you.
However I did not offer this suggestion for myself, because now that I have run into the problem I now know how to avoid it and so I will just do my learning related to the time
package using my GoLand IDE.
I suggested the change for the benefit of people in the future who come to goplay.tools who have no idea of the limitation, and when things don't work as expected they assume their code is the problem, not the platform.
And for that reason, it would never occur to them that they would need to open up the settings, click the environment tab and switch to WebAssembly for time.Now()
to return a correct result.
Said another way, I made the suggestion so that goplay.tools might become more consistent with the principle of least surprise when someone who was trying to learn how to format time values uses goplay.tools in conjunction withtime.Now()
. #fwiw
As a complete aside, I notice you are from Lviv, Ukraine. How are things going for you, your family and your community given the war of Russian aggression? My heart goes out to your country people and I hope for your collective benefit that there is a resolution to the war soon than later.
@mikeschinkel I propose to show this warning as a warning in code editor. It should mark all points where time.Now()
is used with explanation.
What do you think?

Perfect!
Will be shipped in a next release.