back to home

aperturerobotics / goscript

Go to TypeScript transpiler

View on GitHub
218 stars
9 forks
6 issues
TypeScriptGoHTML

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing aperturerobotics/goscript in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/aperturerobotics/goscript)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

GoScript [![GoDoc Widget]][GoDoc] [![Go Report Card Widget]][Go Report Card] [GoDoc]: https://godoc.org/github.com/aperturerobotics/goscript [GoDoc Widget]: https://godoc.org/github.com/aperturerobotics/goscript?status.svg [Go Report Card Widget]: https://goreportcard.com/badge/github.com/aperturerobotics/goscript [Go Report Card]: https://goreportcard.com/report/github.com/aperturerobotics/goscript What is GoScript? GoScript is an experimental **Go to TypeScript compiler** that translates Go code to TypeScript at the AST level. The goal is to enable sharing algorithms and business logic between Go backends and TypeScript frontends. > Right now goscript looks pretty cool if you problem is "I want this self-sufficient algorithm be available in Go and JS runtimes". gopherjs's ambition, however, has always been "any valid Go program can run in a browser". There is a lot that goes on in gopherjs that is necessary for supporting the standard library, which goes beyond cross-language translation. > > — nevkontakte, developer of GopherJS 🎯 Why GoScript? Write once, run everywhere. Share your Go algorithms, business logic, and data structures seamlessly between your backend and frontend without maintaining two codebases. **Use cases:** • Sharing business logic between Go services and web apps • Porting Go algorithms to run in browsers • Building TypeScript libraries from existing Go code Go has powerful concurrency support and an excellent standard library. GoScript brings these capabilities to TypeScript with as simple and readable of a translation as possible. **✅ What works:** • Structs, interfaces, methods, and functions with full value semantics • Channels and goroutines (translated to async/await with function coloring) • Pointers and addressability (via VarRef system) • Slices, maps, and built-in types • Control flow (if, for, switch, select, range, defer, etc.) • Type assertions and interface implementations • Closures and anonymous functions • Generics • Reflection • Encoding: encoding/json • Most of the standard library **🚧 In progress:** • Reflection edge cases • Full standard library coverage • Various other edge cases (see GitHub issues) **Important Notes** • Uses JavaScript type (64-bit float, not Go's int types) • No pointer arithmetic ( ) or package • No complex numbers 📖 **Learn more:** Design document | Architecture explainer | Compliance tests 🐛 **Found an issue?** Please open an issue. 🚀 Try It Prerequisites GoScript requires Bun to be installed for running compliance tests: Installation **Option 1: Go Install** **Option 2: NPM** (if available) Compilation 📦 Using Generated Code in Your Project After compiling your Go code to TypeScript, you'll need to set up your project appropriately. TypeScript Configuration Create or update your with these settings: **Important requirements:** • ** or newer** - Required for and other features • ** ** - Enables TypeScript's disposable types for resource management • ** and ** - Allows TypeScript to resolve imports • ** ** - Recommended for modern bundlers You should be able to use any TypeScript bundler to compile the generated TypeScript. 🛠️ Integration & Usage Command Line **Options:** • - Go package to compile (default: ".") • - Output directory for TypeScript files Programmatic API **Go:** **Node.js:** Frontend Frameworks **React + GoScript:** **Vue + GoScript:** 💡 See It In Action See the example/app for a full todo list application using GoScript with tRPC, Drizzle ORM, and React, or example/simple for a comprehensive demo of language features. Example: User Management **Go Code** ( ): **Compile it:** **Generated TypeScript** ( ): **Use in your frontend:** Example: Async Processing with Channels **Go Code:** **Generated TypeScript:** **Use with async/await:** 🤝 How You Can Help • Try GoScript on your code and report issues • Check the compliance tests for current progress • Contribute test cases for edge cases you discover License MIT