Skip to main content
The Go adapter uses cgo to call the Zinc C ABI directly. It returns a []byte slice backed by the shared memory mapping.

Installation

The adapter needs the zinc_core shared library at runtime. Place it on the library search path or link it at build time.

SharedRegion

Create

Creates a new region. Returns an error if the region already exists or if the name or size is invalid.

Open

Opens an existing region. Returns an error if the region does not exist.

Bytes

Returns a []byte slice backed directly by the shared memory mapping. No copying occurs.

Notify

Wait

Returns true if notified, false if timed out.

Close

Complete example

Reader process:

Cgo flags

The adapter uses #cgo LDFLAGS: -lzinc_core -L${SRCDIR}/../../core/target/release to locate the library during development. For production builds, ensure the library is on the system library path or pass -L and -l flags through CGO_LDFLAGS.

Safety

The Bytes() call returns a Go slice pointing to C memory. Go’s garbage collector does not manage this memory. The slice is valid as long as the SharedRegion handle is not closed. Calling Close() and then using the returned slice results in undefined behavior.