Skip to content

Instantly share code, notes, and snippets.

@afonsolopez
Created June 2, 2022 17:30
Show Gist options
  • Select an option

  • Save afonsolopez/1b2a2663cac1557acd2abce812f1ba7d to your computer and use it in GitHub Desktop.

Select an option

Save afonsolopez/1b2a2663cac1557acd2abce812f1ba7d to your computer and use it in GitHub Desktop.
Small setup of a Go program, exposing a function to JavaScript
package main
import (
"fmt"
"syscall/js"
)
func main() {
fmt.Println("Hello WASM")
js.Global().Set("runChecker", js.FuncOf(runCheck))
select {}
}
func runCheck(this js.Value, args []js.Value) interface{} {
return "Hey your string is: " + args[0].String()
}
// Build with "$ GOOS=js GOARCH=wasm go build -o main.wasm"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment