aboutsummaryrefslogtreecommitdiff
path: root/lib/play
AgeCommit message (Collapse)Author
2026-02-02lib/play: set the minimum Go tool version to 1.25.0Shulhan
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2025-01-23all: replace "lib/bytes.AppendXxx" with standard libraryShulhan
Since Go 1.19, package "encoding/binary.BigEndian" support appending byte order.
2025-01-22lib/play: use [T.Error] instead of [T.Fatal] on non-test goroutineShulhan
Using [T.Fatal] on non-test goroutines is not recommended and caught by go vet.
2025-01-16lib/play: handle writing files outside the [GoOptions.Root]Shulhan
Any request to Run or Test Go code that requires writing new files will be joined with the [GoOptions.Root] first. If the final absolute path does not have Root as the prefix it will return an error [os.ErrPermission].
2025-01-16lib/play: refactor functions as methods of type GoShulhan
One of the major issue that we previously have is the Run and Test functions can write file in any unsafe path. Another issue is changing the default GoVersion and Timeout is set on the package level. This changes introduce new type Go as the top level type that can be instantiate with different Root, GoVersion, and Timeout. The instance of Go then can Format, Run, or Test the Go code in their own scope.
2024-12-28lib/play: simplify running Go codeShulhan
This changes remove the field pid in the struct command that wait for process ID, instead execute cmd with Run directly. In the Run function, use the UnsafeRun to store temporary directory and move the statements that writes go.mod and main.go into the method writes of Request. This remove unnecessary unsafeRun function.
2024-12-28lib/play: move all HTTP related methods to its own fileShulhan
2024-12-28lib/play: initialize user's home and cache dir in initShulhan
The home and cache dir should never changes during a running program, so we can set in once during package initialization. If Go failed to get the home and cache it will be set to system temporary directory.
2024-12-28lib/play: implement function to test Go codeShulhan
The Test and HTTPHandleTest functions accept Request with File and Body fields.
2024-12-06lib/play: add custom request to run unsafe directory directlyShulhan
As exceptional, the Run and HTTPHandleRun accept the following request for running program inside custom "go.mod", { "unsafe_run": <path> } The "unsafe_run" define the path to directory relative to HTTP server working directory. Once request accepted it will change the directory into "unsafe_run" first and then run "go run ." directly. Go code that executed inside "unsafe_run" should be not modifiable and safe from mallicious execution.
2024-11-16lib/play: add option to Run with specific Go version and without raceShulhan
The idea is to allow testing Go code on specific Go version. For example, before Go 1.22, the for loop with variable is shared among block statements, which cause every use of that variable is run with the last value.
2024-10-30lib/play: expose the Timeout variableShulhan
By exposing the Timeout, user can set their maximum time the program can run in their playground.
2024-10-04lib/play: new package for formatting and running Go codeShulhan
Package play provides callable APIs and HTTP handlers to format and run Go code, similar to Go playground, but using HTTP instead of WebSocket.