1

Borgo Programming Language

 2 weeks ago
source link: https://borgo-lang.github.io/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Intro

Borgo sits between Go and Rust

Borgo is a new programming language that compiles to Go.

For a high-level overview of the features and instructions on running the compiler locally, check the README.

This playground runs the compiler as a wasm binary and then sends the transpiled go output to the official Go playground for execution.

use fmt

enum NetworkState<T> {
    Loading,
    Failed(int),
    Success(T),
}

struct Response {
    title: string,
    duration: int,
}

fn main() {
    let res = Response {
        title: "Hello world",
        duration: 0,
    }

    let state = NetworkState.Success(res)

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

    fmt.Println(msg)
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK