npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-go-ipc

v0.0.1-beta.7

Published

Cross-language IPC library for Node.js/TypeScript and Go communication

Readme

node-go-ipc

English

Node.js/TypeScript 和 Go 之间的跨语言 IPC 通信库,基于 Unix domain sockets。

安装

Node.js/TypeScript

npm install node-go-ipc

Go

go get github.com/leookun/node-go-ipc

API

Node.js/TypeScript

创建连接

import { Connect } from 'node-go-ipc';

const node = new Connect(socketPath: string, options: NodeOptions);
await node.connect();

注册方法

node.register(methodName: string, handler: (args: any) => any);

示例:

node.register('add', (args: number) => {
  return args + 1;
});

调用远程方法

const result = await node.call(nodeName: string, method: string, args: any);

示例:

const result = await node.call('node1', 'add', 1);
console.log(result); // 2

事件

node.on('connect', () => {});
node.on('disconnect', () => {});
node.on('error', (error: Error) => {});

关闭连接

await node.close();

Go

创建连接

import (
    "github.com/leookun/node-go-ipc/golang/peer"
    "github.com/leookun/node-go-ipc/golang/protocol"
)

p, err := peer.NewPeer(socketPath string, options peer.NodeOptions)
if err != nil {
    // 处理错误
}
err = p.Connect()

注册方法

p.Register(methodName string, handler func(args protocol.MethodArgs) (interface{}, error))

示例:

p.Register("add", func(args protocol.MethodArgs) (interface{}, error) {
    num := args.(float64)
    return num + 1, nil
})

调用远程方法

result, err := p.Call(nodeName string, method string, args interface{})

示例:

result, err := p.Call("node1", "add", 1.0)
if err != nil {
    // 处理错误
}
fmt.Println(result) // 2

关闭连接

p.Close()

配置

interface NodeOptions {
  name: string;                    // 节点唯一名称(必填)
  autoReconnect?: boolean;         // 断线自动重连(默认:true)
  reconnectInterval?: number;      // 重连间隔,单位毫秒(默认:1000)
  reconnectMaxAttempts?: number;   // 最大重连次数(默认:10)
  requestTimeout?: number;         // 请求超时时间,单位毫秒(默认:5000)
  heartbeatInterval?: number;      // 心跳间隔,单位毫秒(默认:3000)
  logLevel?: 'debug' | 'info' | 'warn' | 'error'; // 日志级别(默认:'info')
}

Go 对应配置:

type NodeOptions struct {
    Name                 string
    AutoReconnect        bool
    ReconnectInterval    time.Duration
    ReconnectMaxAttempts int
    RequestTimeout       time.Duration
    HeartbeatInterval    time.Duration
    LogLevel             string
}

示例

Node.js 示例

import { Connect } from 'node-go-ipc';

const node1 = new Connect('connect.socket', {
  name: 'node1',
});

await node1.connect();

node1.register('add', (args: number) => {
  return args + 1;
});

Go 示例

package main

import (
    "fmt"
    "github.com/leookun/node-go-ipc/golang/peer"
)

func main() {
    p, _ := peer.NewPeer("connect.socket", peer.NodeOptions{
        Name: "node2",
    })

    p.Connect()

    result, _ := p.Call("node1", "add", 1.0)
    fmt.Println(result) // 2
}

许可证

MIT