executor

package
v0.0.0-...-604005a Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile 复制文件

func DetectInfiniteLoop

func DetectInfiniteLoop(output string) bool

DetectInfiniteLoop 检测无限循环

func FormatExecutionCommand

func FormatExecutionCommand(cmd []string) string

FormatExecutionCommand 格式化执行命令

Types

type Executor

type Executor interface {
	// Compile 编译代码
	Compile(ctx context.Context, code string, workDir string) (*models.CompileResult, error)

	// Run 运行代码
	Run(ctx context.Context, input string, workDir string, timeLimit, memoryLimit int) (*models.RunResult, error)
}

Executor 代码执行器接口

func GetLanguageExecutor

func GetLanguageExecutor(language models.Language, config *config.SandboxConfig) (Executor, error)

GetLanguageExecutor 获取特定语言的执行器

func NewExecutor

func NewExecutor(language models.Language, langConfig config.LangSpecificConfig, securityConfig config.SecurityConfig) Executor

NewExecutor 创建语言执行器

type LanguageExecutor

type LanguageExecutor struct {
	// contains filtered or unexported fields
}

LanguageExecutor 针对特定语言的执行器

func (*LanguageExecutor) Compile

func (e *LanguageExecutor) Compile(ctx context.Context, code string, workDir string) (*models.CompileResult, error)

Compile 编译代码

func (*LanguageExecutor) Run

func (e *LanguageExecutor) Run(ctx context.Context, input string, workDir string, timeLimit, memoryLimit int) (*models.RunResult, error)

Run 运行代码

Jump to

Keyboard shortcuts

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