-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
39 lines (39 loc) · 1.17 KB
/
Copy pathdoc.go
File metadata and controls
39 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Package goru provides a WebAssembly-based sandbox for executing untrusted
// Python and JavaScript code safely.
//
// # Overview
//
// goru runs code in isolated WASM modules with zero default capabilities.
// Filesystem, network, and other system access must be explicitly enabled.
//
// # Basic Usage
//
// exec, _ := executor.New(hostfunc.NewRegistry())
// defer exec.Close()
//
// // Stateless execution
// result := exec.Run(ctx, python.New(), `print("hello")`)
// fmt.Println(result.Output)
//
// // Session with persistent state
// session, _ := exec.NewSession(python.New())
// session.Run(ctx, `x = 42`)
// session.Run(ctx, `print(x)`) // 42
//
// # Enabling Capabilities
//
// // HTTP access
// result := exec.Run(ctx, python.New(), code,
// executor.WithAllowedHosts([]string{"api.example.com"}))
//
// // Filesystem access
// result := exec.Run(ctx, python.New(), code,
// executor.WithMount("/data", "./input", hostfunc.MountReadOnly))
//
// // Key-value store
// result := exec.Run(ctx, python.New(), code,
// executor.WithKV())
//
// See the [executor], [hostfunc], [language/python], and [language/javascript]
// packages for detailed API documentation.
package goru