Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Embedding Final in Go

Final was designed first as a language for AI tools, and second as a general-purpose stack language you can drive from Go. The Introduction and Features survey already mentioned embedding; this section is the host API guide.

You embed Final by creating a Session, then calling Send with a string of Final source. Each Send is one interpret/compile batch: the script runs to completion (or faults), captured stdout comes back as a string, and dictionary state in that Session persists for later Sends.

PageContents
2 Embedding Modelsfinalgo (simple) vs finalembed (host types); Session / Send / async; LockSession; agent sample app
Security RestrictionsDisabled-set capability model for sandboxed AI and other hosts

Already covered elsewhere

Which package?

  • Prefer finalgo for agentic and request/response hosts: create a Session, Send scripts, optionally expose FinalTool to an LLM. That is the path used by the sample chat app.
  • Use finalembed when the host must register its own Go types so Final scripts can construct and drive them (widgets, domain objects, generators).

Details and tradeoffs: 2 Embedding Models.