explaingit

borgo-lang/borgo

4,626RustAudience · developerComplexity · 3/5Setup · moderate

TLDR

Borgo is a programming language that compiles to standard Go code, adding Rust-style type safety features like algebraic data types, Option, Result, and pattern matching while staying fully compatible with existing Go packages.

Mindmap

mindmap
  root((Borgo))
    What it does
      Transpiles to Go
      Rust-style types
      Go compatibility
    Key features
      Algebraic data types
      Option and Result
      Pattern matching
      Error propagation
    Tech stack
      Rust compiler
      Go output
      Cargo build
    Use cases
      Safer Go programs
      Type-driven design
      Go with better types
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Write Go programs with exhaustive pattern matching and algebraic data types to catch more bugs at compile time

USE CASE 2

Use Option types instead of nil pointers to eliminate null pointer panics in Go code

USE CASE 3

Replace Go's multiple-return error convention with Result types and use the ? operator for concise error propagation

USE CASE 4

Try the language in the online playground without installing anything to see if the type model fits your project

Tech stack

RustGoCargo

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Rust and Cargo to build the compiler from source, an online playground is available for trying the language without installing anything.

In plain English

Borgo is a programming language that converts (transpiles) to Go. The idea behind it is to sit somewhere between Go and Rust in terms of expressiveness. Go is simple and easy to learn but has limited type safety features. Rust has stronger type safety but is considerably more complex. Borgo tries to take the ergonomic type features from Rust-style languages and make them available while still producing standard Go code that runs with the normal Go toolchain. Borgo code looks similar to Rust with a few differences. It supports algebraic data types, which are a way of describing values that can be one of several named shapes. For example, a network response could be Loading, Failed with an error code, or Success with a string. You then write a match statement that handles each case, and the compiler confirms you have covered all of them. This is more expressive than Go's typical approach of returning multiple values or using separate boolean flags. Borgo also replaces Go's nil pointer concept with Option types and replaces Go's multiple-return error convention with Result types. These are common patterns in languages like Rust and Swift that make it harder to accidentally ignore errors or use values that might not exist. The ? operator provides a shorthand for propagating errors without writing the same match statement repeatedly. Borgo is fully compatible with existing Go packages. You can import anything from the Go standard library or third-party Go packages and call them directly from Borgo code. The compiler produces .go files, which you then run or build using the regular go command. The compiler itself is written in Rust and requires Cargo, the Rust build tool, to build from source. An online playground is available for trying the language without installing anything locally.

Copy-paste prompts

Prompt 1
Show me how to define a Borgo algebraic data type that represents an API response as Loading, Success with a data string, or Failed with an error code, then match on it.
Prompt 2
How do I import and call a function from the Go standard library, such as encoding/json, from Borgo code?
Prompt 3
Translate this Go function that returns a value and an error into Borgo using Result types and the ? operator for error propagation.
Open on GitHub → Explain another repo

← borgo-lang on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.