Go bindings to QuickJS: a fast, small, and embeddable ES2020 JavaScript interpreter.
These bindings are a WIP and do not match full parity with QuickJS' API, though expose just enough features to be usable. The version of QuickJS that these bindings bind to may be located here.
QuickJS is not works well with Golang's goroutine, please DO NOT share a quickjs.Runtime cross different goroutines.
$ go get github.com/newdash/quickjs- Free
quickjs.Runtimeandquickjs.Contextonce you are done using them. - Free
quickjs.Value's returned byEval()andEvalFile(). All other values do not need to be freed, as they get garbage-collected. - You may access the stacktrace of an error returned by
Eval()orEvalFile()by casting it to a*quickjs.Error. - Make new copies of arguments should you want to return them in functions you created.
- Make sure to call
runtime.LockOSThread()to ensure that QuickJS always operates in the exact same thread.
Value.Interface- inner references will be freedValue.InterfaceAndFree- current & inner reference will be freedValue.GetString(ByUint32)- new reference will be freedValue.GetInt64(ByUint32)- new reference will be freedValue.GetFloat64(ByUint32)- new reference will be freedValue.DynamicCall(WithContext)- args references will freed
QuickJS is released under the MIT license.
QuickJS bindings are copyright Kenta Iwasaki, with code copyright Fabrice Bellard and Charlie Gordon.