Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

borgo

> 编程语言
Open source

Borgo is a statically typed language that compiles to Go.

4.6K stars0 likes0 views
WebsiteGitHub

About

Borgo is a statically typed language that compiles to Go.

The Borgo Programming Language


I want a language for writing applications that is more expressive than Go but less complex than Rust.

Go is simple and straightforward, but I often wish it offered more type safety. Rust is very nice to work with (at least for single threaded code) but it's too broad and complex, sometimes painfully so.

Borgo is a new language that transpiles to Go. It's fully compatible with existing Go packages.

Borgo syntax is similar to Rust, with optional semi-colons.

Tutorial

Check out the online playground for a tour of the language.

You can also take a look at test files for working Borgo code:

  • codegen-emit.md
  • infer-expr.md
  • infer-file.md

Features

Algebraic data types and pattern matching

use fmt

enum NetworkState {
    Loading,
    Failed(int),
    Success(string),
}

let msg = match state {
    NetworkState.Loading => "still loading",
    NetworkState.Failed(code) => fmt.Sprintf("Got error code: %d", code),
    NetworkState.Success(res) => res,
}

Option<T> instead of nil

// import packages from Go stdlib
use fmt
use os

let key = os.LookupEnv("HOME")

match key {
    Some(s) => fmt.Println("home dir:", s),
    None => fmt.Println("Not found in env"),
}

Result<T, E> instead of multiple return values

use fmt
use net.http

fn makeRequest() -> Result<int, error> {
    let request = http.Get("http://example.com")

    match request {
        Ok(resp) => Ok(resp.StatusCode),
        Err(err) => Err(fmt.Errorf("failed http request %w", err))
    }
}

Error handling with ? operator

use fmt
use io
use os

fn copyFile(src: string, dst: string) -> Result<(), error> {
    let stat = os.Stat(src)?

    if !stat.Mode().IsRegular() {
        return Err(fmt.Errorf("%s is not a regular file", src))
    }

    let source = os.Open(src)?
    defer source.Close()

    let destination = os.Create(dst)?
    defer destination.Close()

    // ignore number of bytes copied
    let _ = io.Copy(destination, source)?

    Ok(())
}

Guessing game example

Small game from the Rust book, implemented in Borgo.

Things to note:

  • import packages from Go stdlib
  • strconv.Atoi returns an Option<int>
  • Reader.ReadString returns a Result<string, error> (which can be unwrapped)
…

Running locally

Borgo is written in Rust, so you'll need cargo.

To compile all .brg files in the current folder:

$ cargo run -- build

The compiler will generate .go files, which you can run as normal:

# generate a go.mod file if needed
# $ go mod init foo
$ go run .

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustcompilergolangprogramming-languagerust-lang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言