command
Version:
v0.2.0
Opens a new window with list of versions in this module.
Published: Jul 5, 2026
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Calling JavaScript from Go
Load a script that defines functions, then drive it from Go: fetch a function
global, call it with converted arguments, and read the result back.
go run ./examples/call_js
Expected output:
Hello, world!
stats: map[count:4 mean:5 total:20]
Key points:
vm.GetGlobal(name) fetches a value (e.g. a function) defined by the script.
vm.Call(fn, this, args...) invokes a callable JS value from Go. Pass
gojs.Undefined for this unless calling a method.
- Convert across the boundary with
vm.FromGo (Go → JS) and vm.ToGo /
vm.ToString (JS → Go).
Documentation
¶
Example: calling JavaScript functions from Go.
The host loads a script that defines functions, then invokes them from Go
with converted arguments and reads the results back.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.