Go → Node.js N-API framework. The Go-ecosystem counterpart to napi-rs and Zig node-api.
napi-go-infra is source-distributed. It does not ship prebuilt
.node binaries for downstream consumption. Downstream builders (e.g.
ultraviolet-builder) add napi-go-infra as a workspace dependency,
import the Go package and the C shim, and produce their own
per-platform-arch .node artifacts.
The one binary this package does build is examples/hello/, a reference
binding used as a smoke test. It is not published.
Early. V1 surface covers synchronous value marshaling and Go-owned
handles. Threadsafe callbacks (Go goroutine → JS) and struct codegen
are deferred. See src/ and include/napi_go.h for the actual surface.
A downstream builder wires in napi-go-infra by:
- Adding
"napi-go-infra": "workspace:*"todependencies. - Declaring a Go entry file (
//exports for each N-API function) plus a C shim that callsnapi_go_registerto bind them. - Calling
buildNapiGoAddon({ ... })fromscripts/build.mts— the same helper that buildsexamples/hellohere.
See examples/hello/ for the minimal shape and cli/src/build.mts for
the options accepted by the build driver.
- Go >= 1.21 on
PATH(c-archivemode + cgo). - A C compiler (
clangon macOS/Linux, MSVC or mingw on Windows). - Node.js headers (automatically resolved from the running node executable during builds).
Go is not currently pinned via build-infra's tool-checksums; follow
the system-toolchain pattern used by iocraft-builder for rustc.