GSET
Targets

Go Target

The default backend — and the only one implemented so far.

Implemented

Go is GSET's default backend: -t go (the default), and the target the M1 milestone proved end to end.

The generated file is a complete runnable Go program:

package main

import "fmt"

func fib(n int) int {
	if n < 2 {
		return n
	}
	return (fib((n - 1)) + fib((n - 2)))
}

func main() {
	fmt.Println(fib(10))
}

Verified example

$ gset transpile tests/corpus/py/fib.py -t go -o fib.go && go vet fib.go   # clean
$ gset run tests/corpus/py/fib.py -t go
55

The typing rule that keeps Go output valid

The IR's semantic pass infers types from literals, annotations, arithmetic, calls, and collection elements. Where the source is genuinely dynamic the type stays Unknown and the backend picks a default, which is what the gset-untyped warning reports.

Annotate source that you want typed output from:

def fib(n: int) -> int:   # → func fib(n int) int
    ...

Watch out

  • fmt import is automatic. Any use of print triggers import "fmt".
  • The M1 gate is exactly this pair: gofmt and go vet accept every corpus emit. If the backend ever emits invalid Go, the CI gate fails, not a user at runtime.

On this page