Making some changes for GopherJS playground update#1404
Merged
grantnelson-wf merged 1 commit intogopherjs:masterfrom Jan 23, 2026
Merged
Making some changes for GopherJS playground update#1404grantnelson-wf merged 1 commit intogopherjs:masterfrom
grantnelson-wf merged 1 commit intogopherjs:masterfrom
Conversation
2ded891 to
d212276
Compare
d212276 to
987be9f
Compare
flimzy
approved these changes
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm making three changes that will help me with the GopherJS playground update that I've been slowly working on:
Adding an indent to some of the JS output so that non-minified looks prettier
Adding a WriteSync hook so that we can redirect the output from
os.Stdoutandos.Stderrto another location other thanconsole.logwhen not running in node.js. This allows us to redirect the output fromfmt.Printto the text box in the playground. To use the hook we just have to set a function like:fmt.Printor anything like that from inside that function otherwise it will get stuck in an infinite loopfdis so that we can color the output, send errors to somewhere different from text, or whatever we want. When the hook is set the buffer is skipped so that we're not mixing Stdout and Stderr text together based on which ever had a newlines. If the hook is set while there is text in the buffer, the buffer is just flushed out with thefdfor the last print which might not be correct for the text that was in the buffer, but it's close enough. We could also just remove thefdif you think that's not useful or skip the buffering.goPrintToConsolethat the playground used to use but it doesn't appear be anything anymorefsor havefsavailable viarequirebut those were a lot of work and ended up not working correctly, so this is the simpler straight forward approach. If you have any other ideas you'd like me to explore first, I'm up for other ways to make this hook work.Moving the Error List out from an internal package so that the error can be broken up into the list of errors