Golang interpreter written in PHP.
use GoPhp\Interpreter;
$interp = Interpreter::create(<<<GO
package main
type person struct {
name string
age int
}
func newPerson(name string) *person {
p := person{name: name}
p.age = 42
return &p
}
func main() {
s := newPerson("John Doe")
println("Hello, " + s.name)
}
GO);
$result = $interp->run();
See examples for more. To run examples:
cd ./examples/{name}
php main.php
This is a toy project, not intended for production use.
To see what is already implemented, refer to tests.
install dependencies:
composer install
run tests:
make test
run make help
for more commands.
- No support for real goroutines, go statements run sequentially