Skip to content

18 · Modules

Go · Go · cgo

Prepare Go exports with cgo and a compatible C compiler. Typed functions, copied public structs and modules use the common bridge. Prepared artifacts need neither Go nor the module cache; retained receivers and variadics require adapters.

On this page

Run locally with the matching plugin and runtime. These examples do not run in the browser playground.

Go / Go · cgo.

46-extern-go.zolo
// parity-timeout-ms:300000

use plugin go::{go}

extern go fn exact(value: int) -> int {
    return value
}

extern go fn upper(value: str) -> str {
    import "strings"
    return strings.ToUpper(value)
}

extern go async fn later(value: int) -> int {
    return value + 1
}

extern go from "./go_fixtures/math.go" use {Add}

print(exact(9007199254740993)) // expected: 9007199254740993

print(upper("hello Go")) // expected: HELLO GO

print(Add(left: 20, right: 22)) // expected: 42

print(await later(41)) // expected: 42

Requires the Zolo CLI/host — open in the playground or run locally.

Preparation and deployment

Source-free packaging can retain prepared foreign artifacts, but does not remove runtime or platform dependencies. VM, native and LLVM hosting are covered; foreign bindings reject unsupported WebAssembly targets. The recent provider acceptance covers Windows x64. Python acceptance specifically covers CPython 3.12; other platforms need their own verification.

Reference overview

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br