MCPcopy Create free account
hub / github.com/akshayganeshen/napi-go

github.com/akshayganeshen/napi-go @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
146 symbols 291 edges 29 files ⚖ MIT 6 documented · 4% updated 4y ago★ 593 open issues

Browse by type

Functions 111 Types & classes 35
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

napi-go

A Go library for building Node.js Native Addons using Node-API.

Usage

Use go get to install the library:

go get -u github.com/akshayganeshen/napi-go

Then use the library to define handlers:

package handlers

import "github.com/akshayganeshen/napi-go"

func MyHandler(env napi.Env, info napi.CallbackInfo) napi.Value {
  return nil
}

Next, create a main.go that registers all module exports:

package main

import "github.com/akshayganeshen/napi-go/entry"

func init() {
  entry.Export("myHandler", MyHandler)
}

func main() {}

Finally, build the Node.js addon using go build:

go build -buildmode=c-shared -o "example.node" .

The output .node file can now be imported via require:

const example = require("./example.node");

example.myHandler();

JS Helpers

In addition to the Node-API exposed via package napi, the napi-go/js package provides functions similar to the syscall/js standard library.

package main

import (
  "github.com/akshayganeshen/napi-go/entry"
  "github.com/akshayganeshen/napi-go/js"
)

func init() {
  entry.Export("myCallback", js.AsCallback(MyCallback))
}

func MyCallback(env js.Env, this js.Value, args []js.Value) any {
  return map[string]any{
    "message": "hello world",
    "args":    args,
  }
}

func main() {}

Examples

Check out the example addons in docs/examples.

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 71
Method 40
Struct 15
TypeAlias 13
Interface 4
FuncType 3

Languages

Go100%

Modules by API surface

instance_data.go44 symbols
js_native_api.go28 symbols
js/promise.go11 symbols
node_api.go10 symbols
js/env.go10 symbols
docs/examples/js/main.go7 symbols
status.go4 symbols
docs/examples/describe-args/main.go4 symbols
docs/examples/hello-world/main.go3 symbols
docs/examples/callback/main.go3 symbols
docs/examples/async-promise/main.go3 symbols
async_work.go3 symbols

For agents

$ claude mcp add napi-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page