-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb8047f
commit a591646
Showing
15 changed files
with
120 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
piston "github.com/milindmadhukar/go-piston" | ||
) | ||
|
||
func main() { | ||
client := piston.CreateDefaultClient() | ||
output, err := client.Execute("python", "", // Passing language. Since no version is specified, it uses the latest supported version. | ||
[]piston.Code{ | ||
{Content: "inp = input()\nprint(inp[::-1])"}, | ||
}, // Passing Code. | ||
piston.Stdin("hello world"), // Passing input as "hello world". | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(output.GetOutput()) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package gopiston | ||
|
||
import "time" | ||
|
||
// Function to pass the Params struct. | ||
type Param func(*Params) | ||
|
||
// Struct that contains all piston parameters. | ||
type Params struct { | ||
requestBody *RequestBody | ||
} | ||
|
||
// Stdin (optional) The text to pass as stdin to the program. Must be a string or left out. Defaults to blank string. | ||
func Stdin(input string) Param { | ||
return func(param *Params) { | ||
param.requestBody.Stdin = input | ||
} | ||
} | ||
|
||
// Args (optional) The arguments to pass to the program. Must be an array or left out. Defaults to []. | ||
func Args(args []string) Param { | ||
return func(param *Params) { | ||
param.requestBody.Args = args | ||
} | ||
} | ||
|
||
// CompileTimeout (optional) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a "time.Duration" object. Defaults to 10 seconds. | ||
func CompileTimeout(timeout time.Duration) Param { | ||
|
||
return func(param *Params) { | ||
param.requestBody.CompileTimeout = int(timeout.Seconds()) | ||
} | ||
} | ||
|
||
// RunTimeout (optional) The maximum time allowed for the run stage to finish before bailing out in milliseconds. Must be a "time.Duration" object. Defaults to 3 seconds. | ||
func RunTimeout(timeout time.Duration) Param { | ||
|
||
return func(param *Params) { | ||
param.requestBody.RunTimeout = int(timeout.Seconds()) | ||
} | ||
} | ||
|
||
// CompileMemoryLimit (optional) The maximum amount of memory the compile stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit) | ||
func CompileMemoryLimit(limit int) Param { | ||
return func(param *Params) { | ||
param.requestBody.CompileMemoryLimit = limit | ||
} | ||
|
||
} | ||
|
||
// RunMemoryLimit (optional) The maximum amount of memory the run stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit) | ||
func RunMemoryLimit(limit int) Param { | ||
|
||
return func(param *Params) { | ||
param.requestBody.RunMemoryLimit = limit | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
go clean -testcache && go test ./... -v -cover | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' | sed ''/RUN/s//$(printf "\033[33mRUN\033[0m")/'' | GREP_COLOR='01;32' grep -E --color 'ok.*$|^.*ok.*$|$' |
This file contains 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