goplay

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultUserAgent          = "goplay.tools/1.0 (http://goplay.tools/)"
	DefaultPlaygroundURL      = "https://play.golang.org"
	DefaultGoTipPlaygroundURL = "https://gotipplay.golang.org"
)

Variables

View Source
var ErrSnippetNotFound = errors.New("snippet not found")

ErrSnippetNotFound is snippet not found error

View Source
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

func IsCompileError(err error) bool

IsCompileError checks if error is CompileFailedError

func ValidateContentLength added in v1.1.0

func ValidateContentLength(itemLen int) error

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 NewClient added in v1.5.1

func NewClient(baseUrl, userAgent string, timeout time.Duration) *Client

NewClient returns new Go playground 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, src []byte) (*CompileResponse, error)

Compile runs code in goplayground and returns response

func (*Client) GetSnippet added in v1.5.1

func (c *Client) GetSnippet(ctx context.Context, snippetID string) (*Snippet, error)

GetSnippet returns snippet from Go playground

func (*Client) GoImports added in v1.5.1

func (c *Client) GoImports(ctx context.Context, src []byte) (*FmtResponse, error)

GoImports performs Goimports

func (*Client) Share added in v1.5.1

func (c *Client) Share(ctx context.Context, src io.Reader) (string, error)

Share shares snippet to go playground

type CompileEvent

type CompileEvent struct {
	Message string
	Kind    string
	Delay   time.Duration
}

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

type FmtResponse struct {
	Body  string
	Error string
}

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 Snippet added in v1.1.0

type Snippet struct {
	FileName string
	Contents string
}

Snippet represents shared snippet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL