Currently playground ends every output with "Program exited.".
It is confusing because sometimes program was not run at all.
I propose the behaviour below.
In case of success:
Hello, playground
Program exited.
Vet errors and successful run of a program:
prog.go:8: Println arg list ends with redundant newline
Go vet exited.
Hello, playground
Program exited.
In case of failed compilation:
prog.go:4:2: imported and not used: "fmt"
prog.go:8:2: undefined: qwe
Go build failed.
In case of failed test:
=== RUN TestOne
--- FAIL: TestOne (0.00s)
got:
1
want:
2
FAIL
Program exited.
In case of program timeout. Display the recorded output before the program was killed. This might require returning both Errors and Events fields. #10590
Hello, playground
Hello, playground
...
Program was killed due timeout.
Bonus parts (implement in that does not break /compile interface):
UP: removed exit status from proposal.
UP2: added bonus parts
Maybe something like "all tests passed" / "N tests failed" when running tests and/or examples?
SGTM. The exit codes may not be needed. The point of the current "Program exited." is that the output is streaming so that line just says "it's done". The exact exit status is not usually terribly interesting.
My vote: only print non-zero exit status and only when not running tests.
Most of the time it's uninteresting but if you do os.Exit(3) that's output from the program that's just discarded now.
@rsc, thanks, I have fixed examples regarding exit status.
@jimmyfrasche I will look into that. I have started sketching it and passing exit status might be too tricky to implement without breaking interfaces. Anyway, I will keep that in mind because I like the idea to show "Program exited with the code 3." in case of non zero exit code.
Please see the images and let me know what you think.








ping @andybons @dmitshur @bradfitz @bcmills for the opinion :-)
One format I am not sure about is the messages when program has exited with non-zero status. What do you think is the best?
Program exited: exit status is 3.
Program exited: status is 3.
Program exited: code is 3.
I am inclined toward the 3rd option.
Change https://golang.org/cl/141477 mentions this issue: playground.js: make output of "Run" clearer
Change https://golang.org/cl/141478 mentions this issue: playground: make outcome of "Run" clearer
The precedence is that go run reports exit status 3
Ok good. I somehow missed that new stuff. It was decided already, I will use it.
Change https://golang.org/cl/142637 mentions this issue: Dockerfile: include updated x/tools containing CL 141477
@dmitshur, this ticket can be closed after the deployment.
Change https://golang.org/cl/144078 mentions this issue: playground: fix the test broken by CL 141478
@ysmolsky It's deployed now. Thank you!
Most helpful comment
@rsc, thanks, I have fixed examples regarding exit status.
@jimmyfrasche I will look into that. I have started sketching it and passing exit status might be too tricky to implement without breaking interfaces. Anyway, I will keep that in mind because I like the idea to show "Program exited with the code 3." in case of non zero exit code.