Skip to content

go_script

Run a Go program under the yaegi interpreter. Stdin is the run context JSON, stdout is the result JSON.

Sourceinternal/agents/workflow/nodes/go_script.go
When to useLogic that needs real Go — string manipulation, math, JSON shaping, custom predicates. Use http / transform for I/O; this node is pure compute.

Schema

FieldTypeRequiredNotes
codetextarea (template)Go source. Standard library available; no third-party imports.
timeout_secintPer-call timeout. Default 30.

Output

FieldTypeWhat
resultanyJSON value parsed from script stdout. When result is an object, its keys are merged into .Node.<id>.* for direct template access.
stderrstringCaptured 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.

Pair with

  • transform — when a Go template would do.
  • shell — when you actually do need to spawn a process.
Built with ❤️ by a developer, for developers.