Documentation ¶
Index ¶
- Constants
- Variables
- func IsCompileError(err error) bool
- func ValidateContentLength(itemLen int) error
- type Client
- func (c *Client) Compile(ctx context.Context, src []byte) (*CompileResponse, error)
- func (c *Client) GetSnippet(ctx context.Context, snippetID string) (*Snippet, error)
- func (c *Client) GoImports(ctx context.Context, src []byte) (*FmtResponse, error)
- func (c *Client) Share(ctx context.Context, src io.Reader) (string, error)
- type CompileEvent
- type CompileFailedError
- type CompileResponse
- type FmtResponse
- type Snippet
Constants ¶
const ( DefaultUserAgent = "goplay.tools/1.0 (http://goplay.tools/)" DefaultPlaygroundURL = "https://play.golang.org" )
Variables ¶
var ErrSnippetNotFound = errors.New("snippet not found")
ErrSnippetNotFound is snippet not found error
var ErrSnippetTooLarge = fmt.Errorf("code snippet too large (max %d bytes)", maxSnippetSize)
ErrSnippetTooLarge is snippet max size limit error
Functions ¶
func IsCompileError ¶ added in v1.1.0
IsCompileError checks if error is CompileFailedError
func ValidateContentLength ¶ added in v1.1.0
ValidateContentLength validates snippet size
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) 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 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