Documentation ¶
Overview ¶
Package language is used to compile and run untrusted code securely. The heavy lifting is done by the great isolate library. This library comes with a lot of built-in languages, and it's easy to implement your own languages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrorLanguageNotFound = errors.New("language not found")
Functions ¶
This section is empty.
Types ¶
type Language ¶
type Language interface { ID() string DisplayName() string DefaultFilename() string Compile(ctx context.Context, s sandbox.Sandbox, f sandbox.File, stderr io.Writer, extras []sandbox.File) (*sandbox.File, error) //TODO remove extras? Run(ctx context.Context, s sandbox.Sandbox, binary sandbox.File, stdin io.Reader, stdout io.Writer, tl time.Duration, ml memory.Amount) (*sandbox.Status, error) }
Language is the main building block of this package, it's used to compile a source file and then run the resulting binary.
func ListExcept ¶ added in v0.4.0
ListExcept returns a slice of languages except some.
type ListStore ¶
type ListStore struct {
LanguageList []Language
}
ListStore is a basic implementation (and probably only realistic, so maybe an interface is not really necessary) of a Store.
func NewListStore ¶
func NewListStore() *ListStore
type NotFoundError ¶ added in v0.4.0
type NotFoundError struct {
ID string
}
func (NotFoundError) Error ¶ added in v0.4.0
func (n NotFoundError) Error() string
func (NotFoundError) Is ¶ added in v0.4.0
func (n NotFoundError) Is(err error) bool
type Store ¶
type Store interface { Register(id string, l Language) List() []Language Get(id string) (Language, error) }
Store is an interface which is used to capture the notion of storing languages. Via it's Store.Register method it's possible to override the underlying ID of the language for the outside world.
var DefaultStore Store
DefaultStore is a store which all Language objects should register themselves in.
type Test ¶ added in v0.4.0
type Test struct { Name string Language Language Source string Input string ExpectedOutput string ExpectedVerdict sandbox.Verdict TimeLimit time.Duration MemoryLimit memory.Amount }
Test is a struct that holds a test for a language.