mirror of
https://github.com/goplus/llgo.git
synced 2025-09-26 19:51:21 +08:00

- Consolidate _demo, _pydemo, _embdemo into single _demo directory structure - Organize demos by language: _demo/{go,py,c,embed}/ - Categorize demos based on imports: - Python library demos (py imports) → _demo/py/ - C/C++ library demos (c/cpp imports) → _demo/c/ - Go-specific demos → _demo/go/ - Embedded demos → _demo/embed/ - Move C-related demos (asm*, cabi*, cgo*, linkname, targetsbuild) from go/ to c/ - Update all path references in README.md and GitHub workflows - Improve demo organization and navigation as requested in #1256 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
25 lines
332 B
Go
25 lines
332 B
Go
package main
|
|
|
|
/*
|
|
#cgo pkg-config: python3-embed
|
|
#include <Python.h>
|
|
*/
|
|
import "C"
|
|
import "fmt"
|
|
|
|
func Initialize() {
|
|
C.Py_Initialize()
|
|
}
|
|
|
|
func Finalize() {
|
|
C.Py_Finalize()
|
|
}
|
|
|
|
func Run(code string) error {
|
|
if C.PyRun_SimpleString(C.CString(code)) != 0 {
|
|
C.PyErr_Print()
|
|
return fmt.Errorf("failed to run code")
|
|
}
|
|
return nil
|
|
}
|