-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
211 lines (160 loc) · 5.62 KB
/
types.go
File metadata and controls
211 lines (160 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package gowandbox
import (
"bufio"
)
const defaultUrl string = "https://wandbox.org/api/"
// Url to WandBox API
var WandBoxUrl string = defaultUrl
// Changes the default WandBox URL, useful to use with your own instance of WandBox
func ChangeWandBoxUrl(url string) {
WandBoxUrl = url
}
// Resets the WandBox URL used
func ResetWandBoxUrl() {
WandBoxUrl = defaultUrl
}
/*
Program Struct, used while compiling
Takes in the filename, and code
*/
type Program struct {
File string `json:"file"`
Code string `json:"code"`
}
/*
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.
*/
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"`
}
/*
GWBNDProgram struct, to be used when posting to `/compile.ndjson`
The fields are very similar to GWBProgram, but without the SaveCode option
*/
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"`
}
/*
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 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"`
}
/*
Reader to stream data from the `/compile.ndjson` endpoint.
Data can be obtained by calling the `Next()` method.
*/
type GWBNDReader struct {
source *bufio.Scanner
}
/*
Data returned by the `/compile.ndjson` endpoint.
*/
type GWBNDMessage struct {
Data string `json:"data"`
Type string `json:"type"`
}
/*
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.
*/
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"`
}
/*
Represents a WandBox user.
Provides the username, and whether the user is logged in or not.
*/
type GWBUser struct {
Login bool `json:"login"`
Username string `json:"username"`
}
/*
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.
*/
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"`
}
type GWBTemplate struct {
Code string `json:"code"`
}