basic

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 3 Imported by: 0

README

Basic execution

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/basic

Expected output:

factorial(10) = 3628800
Go sees: 3.6288e+06

Key points:

  • gojs.New() with no options is a closed sandboxconsole.log produces nothing until you install a PrintProvider.
  • RunString returns the program's completion value (the value of its last expression statement).
  • vm.ToGo converts a JavaScript value into an idiomatic Go value (numbers become float64).

Documentation

Overview

Example: basic script execution.

The simplest embedding: create a VM with a print provider, run a script, and read back its completion value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL