akshayganeshen / napi-go Goto Github PK
View Code? Open in Web Editor NEWGo library for building Node.js Native Addons using Node-API
License: MIT License
Go library for building Node.js Native Addons using Node-API
License: MIT License
hello:
I compiled on windows 10 ,node v16.17.1 reported: Module did not self-register.But on mac and linux version works well,help pls!
i want to use like this:
js code:
let gomodule=require("./gomod.node");
gomodule.func(
function( fromGoObj){
console.info(fromGoObj)
}
);
then how can i write go code?
Your project has been very helpful to me. Thank you very much
I was able to build successfully and then created a js file to run but when I do run it gives the error. I run with node test.mjs. My two go files are like this:
package handlers
import (
"github.com/akshayganeshen/napi-go/js"
)
func MyHandler(env js.Env, this js.Value, args []js.Value) any {
return "hello"
}
package main
import (
"keyring/internal/handlers"
"github.com/akshayganeshen/napi-go/entry"
"github.com/akshayganeshen/napi-go/js"
)
func init() {
entry.Export("myHandler", js.AsCallback(handlers.MyHandler))
}
func main() {}
I run the command below and it fails with the error given. Any ideas?
go build -buildmode=c-shared -o "example.node" cmd/main.go
Info
Macbook Pro M3Pro (2024)
Sonoma 14.4.1
Node: v21.7.3
Go: 1.22.2
I have added the example files, but when I try to build the go to create "example.node", I get this error:
github.com/akshayganeshen/napi-go: invalid flag in #cgo LDFLAGS: -Wl,-no_pie
I am new to go so I'm not quite sure how to fix this, any help would be greatly appreciated!
I've uploaded what I have to this repo:
I'm on an m1 mac and running below command when this error occurs.
CGO_LDFLAGS_ALLOW=-Wl,-no_pie GOOS=darwin GOARCH=arm64 go build -buildmode=c-shared -o "example.node" -a ./cmd
# github.com/akshayganeshen/napi-go
../../../../go/pkg/mod/github.com/akshayganeshen/[email protected]/async_work.go:9:9: undefined: NapiGoAsyncWorkID
../../../../go/pkg/mod/github.com/akshayganeshen/[email protected]/async_work.go:14:49: undefined: Status
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.