Run Go packages in TypeScript

GoScript compiles real Go packages into readable TypeScript, so your Go algorithms, data structures, and selected runtime code can run in Bun, browsers, plugins, and modern app builds without a handwritten port.

goscript-demo
Input main.go
package main

func send(ch chan string) {
    ch <- "ready"
}

func main() {
    ch := make(chan string, 1)
    go send(ch)

    msg := <-ch
    println("received:", msg)
}
Output main.ts
import * as $ from "@goscript/builtin/index.js"

export async function send(
  ch: $.Channel<string> | null
): globalThis.Promise<void> {
  await $.chanSend(ch, "ready")
}

export async function main(): globalThis.Promise<void> {
  let ch = $.makeChannel<string>(1, "", "both")
  queueMicrotask(async () => { await send(ch) })

  let msg = await $.chanRecv(ch)
  $.println("received:", msg)
}

Built for real Go code

๐ŸŽฏ

One source of truth

Keep core logic in Go and publish generated TypeScript packages for frontends, plugins, browser demos, and Bun-based tooling.

โœ…

Complex Go semantics

Structs, interfaces, methods, generics, channels, goroutines, select, defer, pointers, slices, maps, closures, package initialization, and async call propagation.

๐ŸŒŠ

Spacewave dogfooding

Optimized against Spacewave, a large Go and TypeScript app framework with database, sync, plugin, and browser-runtime workloads.

Install

compile
run