Documentation
¶
Overview ¶
Package gpython provides a script engine implementation using the gpython Python 3 interpreter (https://github.com/go-python/gpython). It allows executing Python scripts at runtime in a pure Go environment without CPython dependencies.
Construction:
eng, _ := gpython.New(ctx)
eng.Init(ctx)
eng.LoadString(ctx, "hello", `print("hello world")`)
result, err := eng.Execute(ctx)
The engine supports hot-reload via StartWatch/StopWatch when the bound Source implements the Watcher interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrGPythonEngineNotInitialized is returned when an operation is invoked // before Init or after Close. ErrGPythonEngineNotInitialized = errors.New("gpython engine not initialized") // ErrGPythonEngineAlreadyInitialized is returned when Init is called on an // already-initialized engine. ErrGPythonEngineAlreadyInitialized = errors.New("gpython engine already initialized") // ErrGPythonContextNotInitialized is returned when the underlying py.Context // is nil. ErrGPythonContextNotInitialized = errors.New("gpython context not initialized") // ErrGPythonCompileFailed is returned when compiling Python source fails. ErrGPythonCompileFailed = errors.New("gpython compile failed") // ErrGPythonNoScriptLoaded is returned when Execute is called but no script // has been loaded. ErrGPythonNoScriptLoaded = errors.New("gpython no script loaded") // ErrGPythonRunFailed is returned when running Python code fails. ErrGPythonRunFailed = errors.New("gpython run failed") // ErrGPythonFunctionNotFound is returned when CallFunction cannot find the // named function. ErrGPythonFunctionNotFound = errors.New("gpython function not found") // ErrGPythonGlobalNotFound is returned when GetGlobal cannot find the named // variable. ErrGPythonGlobalNotFound = errors.New("gpython global not found") )
Sentinel errors returned by the GPython engine.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.