gozero

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 10 Imported by: 12

README

gozero

gozero: the wannabe zero dependency [language-here] runtime for Go developers

Isolation

Windows

Native isolation on windows is supported only with the PRO version and is implemented via Windows Sandbox (which needs to be activated).

Darwin

OSX implements native isolation via the command sandbox-exec. The command line interface is marked as deprecated, but the system functionality is actively supported, and profiles are still used in well-known software like chrome, firefox.

Linux

On Linux, the functionality is implemented with the default command systemd-run, which should be available on most systems and allow a vast fine-grained sandbox configuration via SecComp and EBPF

Note:

Sandbox is not enabled by default and needs to be used manually through sdk

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoValidEngine is returned when no valid engine is found
	ErrNoValidEngine = errors.New("no valid engine found")

	// ErrNoEngines is returned when no engines are provided
	ErrNoEngines = errors.New("no engines provided")
)

Functions

This section is empty.

Types

type Gozero

type Gozero struct {
	Options *Options
}

Gozero is executor for gozero

func New

func New(options *Options) (*Gozero, error)

New creates a new gozero executor

func (*Gozero) Eval

func (g *Gozero) Eval(ctx context.Context, src, input *Source, args ...string) (*types.Result, error)

Eval evaluates the source code and returns the output input = stdin , src = source code , args = arguments

type Options

type Options struct {
	Engines []string
	Args    []string

	PreferStartProcess       bool
	Sandbox                  bool
	EarlyCloseFileDescriptor bool
	// When Debug Mode is set to true, Output result will contain
	// more debug information
	DebugMode bool
	// contains filtered or unexported fields
}

type Source

type Source struct {
	Variables       []types.Variable
	Temporary       bool
	CloseAfterWrite bool
	Filename        string
	File            *os.File
}

Source is a source file for gozero and is meant to contain i/o for code execution

func NewSource

func NewSource() (*Source, error)

func NewSourceWithBytes

func NewSourceWithBytes(src []byte, wantedPattern, dir string) (*Source, error)

func NewSourceWithFile

func NewSourceWithFile(src string) (*Source, error)

func NewSourceWithReader

func NewSourceWithReader(src io.Reader, wantedPattern, dir string) (*Source, error)

func NewSourceWithString

func NewSourceWithString(src, wantedPattern, dir string) (*Source, error)

func (*Source) AddVariable

func (s *Source) AddVariable(vars ...types.Variable)

func (*Source) Cleanup

func (s *Source) Cleanup() error

func (*Source) Close

func (s *Source) Close() error

func (*Source) ReadAll

func (s *Source) ReadAll() ([]byte, error)

Directories

Path Synopsis
cmdexec package is wrapper around os/exec and handles common use cases while executing commands.
cmdexec package is wrapper around os/exec and handles common use cases while executing commands.
examples
simple_darwin command
simple_linux command
simple_windows command

Jump to

Keyboard shortcuts

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