aboutsummaryrefslogtreecommitdiff
path: root/lib/play/request.go
AgeCommit message (Collapse)Author
2025-01-23all: replace "lib/bytes.AppendXxx" with standard libraryShulhan
Since Go 1.19, package "encoding/binary.BigEndian" support appending byte order.
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: 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-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.