Documentation
¶
Index ¶
- Constants
- Variables
- func IsCompileError(err error) bool
- func ValidateBackend(backend Backend) bool
- type Backend
- type Client
- func (c *Client) Compile(ctx context.Context, req CompileRequest, backend string) (*CompileResponse, error)
- func (c *Client) GetSnippet(ctx context.Context, snippetID string) (*Snippet, error)
- func (c *Client) GoImports(ctx context.Context, src []byte, backend Backend) (*FmtResponse, error)
- func (c *Client) Share(ctx context.Context, src io.Reader) (string, error)
- type CompileEvent
- type CompileFailedError
- type CompileRequest
- type CompileResponse
- type FmtResponse
- type HTTPError
- type Snippet
Constants ¶
const ( DefaultUserAgent = "goplay.tools/1.0 (http://goplay.tools/)" DefaultPlaygroundURL = "https://go.dev/_" // MaxSnippetSize value taken from // https://github.com/golang/playground/blob/master/app/goplay/share.go MaxSnippetSize = 64 * 1024 )
const ( BackendGoCurrent = "" BackendGoPrev = "goprev" BackendGoTip = "gotip" )
const DefaultVersion = 2
Variables ¶
var ErrSnippetNotFound = errors.New("snippet not found")
ErrSnippetNotFound is snippet not found error
Functions ¶
func IsCompileError ¶ added in v1.1.0
IsCompileError checks if error is CompileFailedError
func ValidateBackend ¶ added in v1.13.0
ValidateBackend validates Go Playground backend name.
Types ¶
type Client ¶ added in v1.5.1
type Client struct {
// contains filtered or unexported fields
}
Client is Go Playground API client
func NewDefaultClient ¶ added in v1.5.1
func NewDefaultClient() *Client
NewDefaultClient returns Go Playground client with defaults
func (*Client) Compile ¶ added in v1.5.1
func (c *Client) Compile(ctx context.Context, req CompileRequest, backend string) (*CompileResponse, error)
Compile runs code in goplayground and returns response
func (*Client) GetSnippet ¶ added in v1.5.1
GetSnippet returns snippet from Go playground
type CompileEvent ¶
CompileEvent represents individual event record in CompileResponse
type CompileFailedError ¶ added in v1.1.0
type CompileFailedError struct {
// contains filtered or unexported fields
}
CompileFailedError is build error
func (CompileFailedError) Error ¶ added in v1.1.0
func (c CompileFailedError) Error() string
Error implements error
type CompileRequest ¶ added in v1.13.0
func (CompileRequest) URLValues ¶ added in v1.13.0
func (r CompileRequest) URLValues() url.Values
type CompileResponse ¶
type CompileResponse struct { Body *string Events []*CompileEvent Errors string }
CompileResponse is the response returned from upstream play.golang.org/compile request
func (CompileResponse) GetBody ¶
func (cr CompileResponse) GetBody() string
GetBody returns response body
func (*CompileResponse) HasError ¶
func (cr *CompileResponse) HasError() error
HasError returns error if any occurred
type FmtResponse ¶
FmtResponse is the response returned from upstream play.golang.org/fmt request
func (*FmtResponse) HasError ¶
func (r *FmtResponse) HasError() error
HasError returns error if any occurred
type HTTPError ¶ added in v1.11.1
func IsHTTPError ¶ added in v1.13.0
IsHTTPError checks if passed error is HTTPError.