Goja is an ECMAScript/JavaScript engine written in pure Go.
Goja solves the problem of executing JavaScript code within Go applications without requiring external dependencies or cgo bindings. It implements ECMAScript 5.1 with emphasis on standard compliance, passing nearly all tc39 test262 tests for implemented features. The engine can run substantial JavaScript projects like Babel and the TypeScript compiler. It supports regular expressions, strict mode, sourcemaps, and most ES6 functionality, though ES6 support remains incomplete.
Goja suits scenarios where JavaScript drives a Go-based engine with frequent bidirectional calls between the two languages, since it avoids the overhead of cgo marshalling that would accompany V8 or SpiderMonkey wrappers. Its pure Go implementation means no external build dependencies and portability across all platforms Go supports, making it valuable for research or controlled execution environments. However, if the bulk of computational work happens in JavaScript rather than at language boundaries, V8 or SpiderMonkey will deliver significantly better performance. The tool is not goroutine-safe; each Runtime instance must be used by a single goroutine, though multiple independent instances can coexist. It does not provide setTimeout or setInterval, as these are not part of the ECMAScript standard; a hosting application must supply concurrency control and these functions if needed.
Development activity shows consistent incremental progress on ES6 feature support tracked through an open milestone, with features being added in dependency order. Known incompatibilities exist around JSON parsing of broken UTF-16 surrogates and Date constructor behavior with integer overflow due to reliance on Go's standard library, which the README explicitly documents.