go
experimentalCompiled Go functions, callbacks, copied structs and isolated Go modules.
use plugin go Plugin snippets can be edited in the Playground, but native capabilities are executed locally with the Zolo CLI.
From import to result
- 01Import only what you use
- 02Copy the smallest example
- 03Run it with the Zolo CLI
Functions¶
| Provider | Description |
|---|---|
go |
Go functions, expressions, async and .go imports |
Use Zolo signatures with Go bodies and native imports, then call the compiled function directly.
use plugin go::{go}
extern go fn upper(value: str) -> str {
import "strings"
return strings.ToUpper(value)
}
print(upper("Zolo"))int maps to int64, str to string, bytes to []byte and arrays to slices.
Public structs and string-keyed maps are copied data. Native narrow/unsigned
conversions are checked. Source imports expose exported free functions and
their parameter names. Receiver methods, generics and variadics require a
concrete exported adapter.
Callbacks are Go func adapters valid during the invocation. They return to the owning Zolo runtime and permit nested foreign calls. Do not retain them or call them from an independent goroutine. Async extern work exposes its worker completion as a Zolo Future; a goroutine alone does not define completion. Cancellation closes callback/result delivery. Returned errors and panics within the exported call become structured Zolo errors; unrelated goroutine panics retain Go process semantics.
Global extern go deps and [foreign.go.dependencies] select exact module
versions. Installation records the transitive graph/checksums and private cache.
Compilation uses the sealed environment with downloads and workspaces disabled.
Use the shared install/auto/manual/offline/frozen policies.
Preparation needs Go/cgo and a compatible C compiler. ZOLO_GO selects Go;
CC selects cgo's compiler. Native editor queries use ZOLO_GOPLS.
Inspection never loads the authored library or runs init functions.
VM/native/LLVM dynamic/embed/static artifacts contain machine code, metadata and source snapshots and run without Go, the source files or a module cache. Runtime acceptance covers Windows x64. Hosted wasm-aot and cross-target artifacts are unavailable. See Go examples and dependency policies.