The minimal gojs embedding: create a VM, install a print provider so
console.log has somewhere to go, run a script, and read back the completion
value as a Go value.
go run ./examples/basicExpected output:
factorial(10) = 3628800
Go sees: 3.6288e+06
Key points:
gojs.New()with no options is a closed sandbox —console.logproduces nothing until you install aPrintProvider.RunStringreturns the program's completion value (the value of its last expression statement).vm.ToGoconverts a JavaScript value into an idiomatic Go value (numbers becomefloat64).