go_script
Run a Go program under the yaegi interpreter. Stdin is the run context JSON, stdout is the result JSON.
| Source | internal/agents/workflow/nodes/go_script.go |
| When to use | Logic that needs real Go — string manipulation, math, JSON shaping, custom predicates. Use http / transform for I/O; this node is pure compute. |
Schema
| Field | Type | Required | Notes |
|---|---|---|---|
code | textarea (template) | ✅ | Go source. Standard library available; no third-party imports. |
timeout_sec | int | Per-call timeout. Default 30. |
Output
| Field | Type | What |
|---|---|---|
result | any | JSON value parsed from script stdout. When result is an object, its keys are merged into .Node.<id>.* for direct template access. |
stderr | string | Captured stderr. Useful for debugging. |
Example
json
{
"id": "shape_payload",
"type": "go_script",
"code": "package main\nimport (\"encoding/json\"; \"os\")\nfunc main() {\n var ctx map[string]any\n json.NewDecoder(os.Stdin).Decode(&ctx)\n ev := ctx[\"Event\"].(map[string]any)[\"Payload\"].(map[string]any)\n json.NewEncoder(os.Stdout).Encode(map[string]any{\n \"upper\": ev[\"text\"],\n })\n}"
}Downstream nodes can then reach {{.Node.shape_payload.upper}}.
Why yaegi, not exec
The interpreter runs in-process — no spawn cost, no PATH dependency, no PR for a missing Go toolchain. The cost: stdlib only, slightly slower than compiled Go. For long-running compute, write a connector or job instead.