code

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunnerFactories = map[string]RunnerFactory{
	"golang": NewGolangRunner,
	"python": NewPythonRunner,
	"java":   NewJavaRunner,
}

Functions

This section is empty.

Types

type GolangRunner

type GolangRunner struct {
}

func (*GolangRunner) CheckRuntime

func (r *GolangRunner) CheckRuntime() error

CheckRuntime checks if the Go runtime environment is installed and accessible

func (*GolangRunner) Run

func (r *GolangRunner) Run(code string, args []string) (string, error)

Run compiles and executes the Go code with the provided arguments using "go run"

type JavaRunner

type JavaRunner struct {
}

func (*JavaRunner) CheckRuntime

func (r *JavaRunner) CheckRuntime() error

CheckRuntime checks if the Java runtime environment is installed and accessible

func (*JavaRunner) Run

func (r *JavaRunner) Run(code string, args []string) (string, error)

Run compiles and executes the provided Java code with the provided arguments using "javac" and "java"

type Option

type Option func(*Options)

func WithProgramLangType

func WithProgramLangType(programLangType string) Option

type Options

type Options struct {
	ProgramLangType string
}

type PythonRunner

type PythonRunner struct {
}

func (*PythonRunner) CheckRuntime

func (r *PythonRunner) CheckRuntime() error

CheckRuntime checks if the Python runtime environment is installed and accessible

func (*PythonRunner) Run

func (r *PythonRunner) Run(code string, args []string) (string, error)

Run executes the provided Python code with the provided arguments using "python3"

type Runner

type Runner interface {
	// CheckRuntime check program language runtime
	CheckRuntime() error
	// Run execute code
	// for example: go run code 1 2 3
	Run(code string, args []string) (string, error)
}

func NewGolangRunner

func NewGolangRunner() Runner

NewGolangRunner creates a new instance of GolangRunner

func NewJavaRunner

func NewJavaRunner() Runner

NewJavaRunner creates a new instance of JavaRunner

func NewPythonRunner

func NewPythonRunner() Runner

NewPythonRunner creates a new instance of PythonRunner

type RunnerFactory

type RunnerFactory func() Runner

type Tool

type Tool struct {
	ProgramLangType string
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Tool, error)

New creates a new Tool instance

func (*Tool) Call

func (t *Tool) Call(_ context.Context, input string) (string, error)

Call runs the tool with the given input

func (*Tool) Description

func (t *Tool) Description() string

Description returns the description of the tool

func (*Tool) Name

func (t *Tool) Name() string

Name returns the name of the tool

func (*Tool) Schema

func (t *Tool) Schema() *tool.PropertiesSchema

func (*Tool) Strict

func (t *Tool) Strict() bool

Jump to

Keyboard shortcuts

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