Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var WandBoxUrl string = defaultUrl
Url to WandBox API
Functions ¶
func ChangeWandBoxUrl ¶
func ChangeWandBoxUrl(url string)
Changes the default WandBox URL, useful to use with your own instance of WandBox
Types ¶
type GWBLanguage ¶
type GWBLanguage struct { CompilerOptionRaw bool `json:"compiler-option-raw"` RuntimeOptionRaw bool `json:"runtime-option-raw"` DisplayCompileCommand string `json:"display-compile-command"` Switches []struct { Default interface{} `json:"default"` Name string `json:"name"` DisplayFlags string `json:"display-flags,omitempty"` DisplayName string `json:"display-name,omitempty"` } `json:"switches"` Name string `json:"name"` Version string `json:"version"` Language string `json:"language"` DisplayName string `json:"display-name"` Templates []string `json:"templates"` }
Language returned by the `/list.json` endpoint.
CompilerOptionRaw and RuntimeOptionRaw are booleans stating whether they support passing of these options to `/compile.json` or `/compile.ndjson`.
DisplayCompileCommand shows the command that will be run to execute it.
Name, Version, Language, DisplayName, Templates show information about the language.
Switches is a list of switches that can be used during compile time.
func GetLanguages ¶
func GetLanguages(ctx context.Context) ([]GWBLanguage, error)
Returns a list of languages, maps to the `/list.json` endpoint
type GWBNDMessage ¶
Data returned by the `/compile.ndjson` endpoint.
type GWBNDProgram ¶
type GWBNDProgram struct { Compiler string `json:"compiler"` Code string `json:"code"` Codes []Program `json:"codes"` Options string `json:"options"` CompilerOptionRaw string `json:"compiler-option-raw"` RuntimeOptionRaw string `json:"runtime-option-raw"` Stdin string `json:"stdin"` }
GWBNDProgram struct, to be used when posting to `/compile.ndjson` The fields are very similar to GWBProgram, but without the SaveCode option
func (*GWBNDProgram) Execute ¶
func (g *GWBNDProgram) Execute(ctx context.Context) (GWBNDReader, error)
Method to execute a GWBProgram
If no errors ocurred, the result is returned in the form of a GWBNDReader struct. If the response code is not 200, an error is returned.
Maps to the `/compile.ndjson` endpoint
type GWBNDReader ¶
type GWBNDReader struct {
// contains filtered or unexported fields
}
Reader to stream data from the `/compile.ndjson` endpoint. Data can be obtained by calling the `Next()` method.
func (*GWBNDReader) Next ¶
func (r *GWBNDReader) Next() (GWBNDMessage, error)
Method to read ndjson. Returns a GWNDBMessage struct, which provides the type of the message, and data. On reaching the end, an `io.EOF` error is returned.
type GWBPermLink ¶
type GWBPermLink struct { Parameter struct { Compiler string `json:"compiler"` Code string `json:"code"` Codes []Program `json:"codes"` Options string `json:"options"` Stdin string `json:"stdin"` CompilerOptionRaw string `json:"compiler-option-raw"` RuntimeOptionRaw string `json:"runtime-option-raw"` CreatedAt int64 `json:"created_at"` } `json:"parameter"` Result struct { Status string `json:"status"` Signal string `json:"signal"` CompilerOutput string `json:"compiler_output"` CompilerError string `json:"compiler_error"` CompilerMessage string `json:"compiler_message"` ProgramOutput string `json:"program_output"` ProgramError string `json:"program_error"` ProgramMessage string `json:"program_message"` } `json:"result"` }
Provides information about a permlink
Parameter displays the parameters provided at runtime Note that `CreatedAt` represents the time in ISO-8601 format.
Result shows the output of the compile.
func GetPermLink ¶
func GetPermLink(link string, ctx context.Context) (GWBPermLink, error)
Returns information about a program that was run, given the permlink. Maps to the `/permlink/link` endpoint. If the permlink is not found, and 500 error is returned.
type GWBProgram ¶
type GWBProgram struct { Compiler string `json:"compiler"` Code string `json:"code"` Codes []Program `json:"codes"` Options string `json:"options"` CompilerOptionRaw string `json:"compiler-option-raw"` RuntimeOptionRaw string `json:"runtime-option-raw"` Stdin string `json:"stdin"` SaveCode bool `json:"save"` }
GWBProgram struct, to be used when posting to `/compile.json`
Full compiler list can be seen by using `GetLanguages()`
Code is a string containing the main code that will be run. It will be the entry point to your program.
Codes may contain other files to include while running/compiling
Options, CompilerOptionRaw, RuntimeOptionRaw are strings containing comma separated values. See github.com/melpon/wandbox/blob/master/kennel2/API.rst#sample-1 for more ino
Stdin is a string of newline separated values, which will be passed in as input.
Passing `true` to SaveCode will generate a permlink that will be returned, and the program will be saved to WandBox at that url. Default value is false.
func NewGWBProgram ¶
func NewGWBProgram() *GWBProgram
func (*GWBProgram) Execute ¶
func (g *GWBProgram) Execute(ctx context.Context) (GWBResult, error)
Method to execute a GWBProgram
If no errors ocurred, the result is returned in the form of a GWBResult struct. If the response code is not 200, an error is returned.
Maps to the `/compile.json` endpoint
type GWBResult ¶
type GWBResult struct { Status string `json:"status"` Signal string `json:"signal"` CompilerOutput string `json:"compiler_output"` CompilerError string `json:"compiler_error"` CompilerMessage string `json:"compiler_message"` ProgramOutput string `json:"program_output"` ProgramError string `json:"program_error"` ProgramMessage string `json:"program_message"` Permlink string `json:"permlink"` Url string `json:"url"` }
Result of compiling a program (/compile.json endpoint).
Status and Signal provide information about how the program exited.
CompilerOutput provides output during compile time, and CompilerError provides any errors that occured during compile time. CompilerMessage is a combination of both.
ProgramOutput provides output during runtime, and ProgramError provides any errors that occured during run time. ProgramMessage is a combination of both.
Permlink - permlink of the code, only provided if SaveCode was set to true when compiling. Url - Url to view the code and output in the browser.
type GWBTemplate ¶
type GWBTemplate struct {
Code string `json:"code"`
}
func GetTemplate ¶
func GetTemplate(language string, ctx context.Context) (GWBTemplate, error)
Returns the template for a given language. If the language is not found, an error is returned (bad template). Maps to the `/template/:template` endpoint