Skip to content
goplusPublic

Latest commit

 

History

2,150 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iXGo The Go/XGo Interpreter

Build Status Coverage Status Go Reference

A fast Go interpreter that supports all Go language features, including generics and generic methods.

Go Version

  • Go 1.25 ~ 1.27

Compilers

Platforms

  • macOS
  • Linux
  • Windows
  • WebAssembly

Go ABI

Generics

  • Supports type parameters (generics)
  • Supports generic type aliases
  • Supports generic methods (Go 1.27)

install ixgo command line

go install github.com/goplus/ixgo/cmd/ixgo@latest

install ixgo export command line

go install github.com/goplus/ixgo/cmd/qexp@latest

ixgo command

ixgo             # ixgo repl mode
ixgo run         # run a Go/XGo package
ixgo build       # compile a Go/XGo package
ixgo test        # test a package
ixgo version     # print version
ixgo export      # export Go package to ixgo builtin package

ixgo run mode

Usage: ixgo run [build flags] [package] [arguments...]
  -exp-gc
    	experimental support runtime.GC
  -mod value
    	module download mode to use: readonly, vendor, or mod.
  -ssa
    	print SSA instruction code
  -ssa-trace
    	trace SSA interpreter code
  -tags value
    	a comma-separated list of build tags to consider satisfied during the build
  -v	print the names of packages as they are compiled.
  -x	print the commands.

ixgo repl mode

ixgo                       # run repl mode, support Go/XGo
ixgo repl                  # run repl mode, support Go/XGo
ixgo repl -go              # run repl mode, disable XGo syntax

ixgo test unsupported features

  • test -fuzz
  • test -cover

ifacefuncval (optional)

Alternative to reflectx icall stubs: methods share makeFuncStub. reflectx stores an untagged *makeFuncImpl in addReflectOff and sets tflagIfaceFuncval (1<<6). A patched runtime tags itab.Fun (makeFuncImpl*|1) so interface calls unwrap.

Needs a patched Go 1.25.x, 1.26.x, or 1.27.x and -tags goplus.ifacefuncval. Supported GOARCH: wasm, arm64, amd64, 386.

go install github.com/goplus/reflectx/cmd/iface_patch@latest
iface_patch /path/to/go   # 1.25.x, 1.26.x, or 1.27.x
cd /path/to/go/src && ./make.bash
export GOROOT=/path/to/go
export PATH="$GOROOT/bin:$PATH"
go test -tags goplus.ifacefuncval .
# wasip1: GOOS=wasip1 GOARCH=wasm go test -exec wasmtime -tags goplus.ifacefuncval .

Without the tag, a patched compiler matches official gc. An unpatched compiler still accepts the tag; interface method calls then trap.

You can export GOFLAGS='-tags=goplus.ifacefuncval', or prefix a command: GOFLAGS='-tags=goplus.ifacefuncval' go build (also go run / go test).

See goplus/reflectx cmd/iface_patch.

packages (optional)

Optional optimization packages can be enabled with blank imports:

Package Purpose
directcall Speeds up calls to supported standard-library functions with direct-call adapters. Import ixgo/pkg or individual export packages separately as needed.
directfunc Speeds up calls to interpreted closures and function values with supported signatures, including repeated calls inside loops.
memo Caches results and supported state transformations for eligible recursive functions and receiver methods. Use ixgo.DisableMemo to disable installation for a Context.
import (
	_ "github.com/goplus/ixgo/directcall"
	_ "github.com/goplus/ixgo/directfunc"
	_ "github.com/goplus/ixgo/memo"
)

These packages work with the standard Go toolchain. See each package's documentation for supported paths and limitations.

ixgo demo

The XGo Playground (WebAssembly)

The XGo REPL Playground (WebAssembly)

run simple Go source demo

package main

import (
	"github.com/goplus/ixgo"
	_ "github.com/goplus/ixgo/pkg/fmt"
)

var source = `
package main

import "fmt"

func main() {
	fmt.Println("Hello, World")
}
`

func main() {
	_, err := ixgo.RunFile("main.go", source, nil, 0)
	if err != nil {
		panic(err)
	}
}

run simple XGo source demo

package main

import (
	"github.com/goplus/ixgo"
	_ "github.com/goplus/ixgo/xgobuild"
)

var source = `
languages := [
	"C",
	"Go",
	"Python",
	"JavaScript",
]

echo "XGo :=", languages.join(" * "), "+ Scratch"
`

func main() {
	_, err := ixgo.RunFile("main.xgo", source, nil, 0)
	if err != nil {
		panic(err)
	}
}

build linkname mode

go install -tags linknamefix -ldflags="-checklinkname=0" github.com/goplus/ixgo/cmd/ixgo@latest

use runtime linkname for faster performance iter.Pull/iter.Pull2

ixgo more demo

https://github.com/visualfc/ixgo_demo