We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I build the code to wasm file.
package main import ( "syscall/js" "github.com/mattn/gowasmer/wasmutil" ) func Add(a, b int) int { return a + b } func String(a string) string { println(a) return a } func MultiString(a, b string) string { return a + b } func main() { c := make(chan struct{}) js.Global().Set("String", js.FuncOf(wasmutil.Wrap(String))) js.Global().Set("Add", js.FuncOf(wasmutil.Wrap(Add))) js.Global().Set("MultiString", js.FuncOf(wasmutil.Wrap(MultiString))) <-c }
go run the code. but the function add in wasm is ok, but String and MultiString response emtpy string ?
add
String
MultiString
package main import ( "fmt" "io/ioutil" "log" gowasmer "github.com/mattn/gowasmer" ) func main() { b, err := ioutil.ReadFile("wasm-example") if err != nil { log.Fatal(err) } inst, err := gowasmer.NewInstance(b) if err != nil { log.Fatal(err) } m := inst.Get("Add") r := m.(func([]interface{}) interface{})([]interface{}{1, 3}) fmt.Printf("1 + 3 = %v\n", r) m = inst.Get("String") r = m.(func([]interface{}) interface{})([]interface{}{"haha"}) fmt.Printf("String = %v\n", r) m = inst.Get("MultiString") r = m.(func([]interface{}) interface{})([]interface{}{"aaa", "bbb"}) fmt.Printf("MultiString = %v\n", r) }
1 + 3 = 4 String = MultiString =
please provide more example, thank u.
😁
The text was updated successfully, but these errors were encountered:
No branches or pull requests
question
wasm
I build the code to wasm file.
golang code
go run the code. but the function
add
in wasm is ok, butString
andMultiString
response emtpy string ?run stdout:
please provide more example, thank u.
😁
The text was updated successfully, but these errors were encountered: