{"id":13477642,"url":"https://github.com/borgo-lang/borgo","last_synced_at":"2025-05-13T23:08:10.429Z","repository":{"id":166955995,"uuid":"602833084","full_name":"borgo-lang/borgo","owner":"borgo-lang","description":"Borgo is a statically typed language that compiles to Go.","archived":false,"fork":false,"pushed_at":"2024-10-27T10:07:54.000Z","size":1029,"stargazers_count":4385,"open_issues_count":31,"forks_count":60,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-04-10T15:56:50.493Z","etag":null,"topics":["compiler","golang","programming-language","rust-lang"],"latest_commit_sha":null,"homepage":"https://borgo-lang.github.io","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borgo-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-17T03:04:27.000Z","updated_at":"2025-04-09T08:46:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9034d85-bd8a-4c64-9799-59f2e9732d54","html_url":"https://github.com/borgo-lang/borgo","commit_stats":null,"previous_names":["borgo-lang/borgo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgo-lang%2Fborgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgo-lang%2Fborgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgo-lang%2Fborgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borgo-lang%2Fborgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borgo-lang","download_url":"https://codeload.github.com/borgo-lang/borgo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254041497,"owners_count":22004732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","golang","programming-language","rust-lang"],"created_at":"2024-07-31T16:01:45.535Z","updated_at":"2025-05-13T23:08:05.414Z","avatar_url":"https://github.com/borgo-lang.png","language":"Rust","readme":"# The Borgo Programming Language\n\n![Borgo sits between Go and Rust](https://raw.githubusercontent.com/borgo-lang/borgo-lang.github.io/main/borgo.jpg)\n\n---\n\n![build](https://github.com/borgo-lang/borgo/actions/workflows/ci.yml/badge.svg)\n\nI want a language for writing applications that is more expressive than Go but\nless complex than Rust.\n\nGo is simple and straightforward, but I often wish it offered more type safety.\nRust is very nice to work with (at least for single threaded code) but it's too\nbroad and complex, sometimes painfully so.\n\n**Borgo is a new language that transpiles to Go**. It's fully compatible with\nexisting Go packages.\n\nBorgo syntax is similar to Rust, with optional semi-colons.\n\n# Tutorial\n\nCheck out the **[online playground](https://borgo-lang.github.io/)** for a tour\nof the language.\n\nYou can also take a look at test files for working Borgo code:\n\n- [codegen-emit.md](compiler/test/codegen-emit.md)\n- [infer-expr.md](compiler/test/infer-expr.md)\n- [infer-file.md](compiler/test/infer-file.md)\n\n# Features\n\n## Algebraic data types and pattern matching\n\n```rust\nuse fmt\n\nenum NetworkState {\n    Loading,\n    Failed(int),\n    Success(string),\n}\n\nlet msg = match state {\n    NetworkState.Loading =\u003e \"still loading\",\n    NetworkState.Failed(code) =\u003e fmt.Sprintf(\"Got error code: %d\", code),\n    NetworkState.Success(res) =\u003e res,\n}\n```\n\n---\n\n## `Option\u003cT\u003e` instead of `nil`\n\n```rust\n// import packages from Go stdlib\nuse fmt\nuse os\n\nlet key = os.LookupEnv(\"HOME\")\n\nmatch key {\n    Some(s) =\u003e fmt.Println(\"home dir:\", s),\n    None =\u003e fmt.Println(\"Not found in env\"),\n}\n```\n\n---\n\n## `Result\u003cT, E\u003e` instead of multiple return values\n\n```rust\nuse fmt\nuse net.http\n\nfn makeRequest() -\u003e Result\u003cint, error\u003e {\n    let request = http.Get(\"http://example.com\")\n\n    match request {\n        Ok(resp) =\u003e Ok(resp.StatusCode),\n        Err(err) =\u003e Err(fmt.Errorf(\"failed http request %w\", err))\n    }\n}\n```\n\n---\n\n## Error handling with `?` operator\n\n```rust\nuse fmt\nuse io\nuse os\n\nfn copyFile(src: string, dst: string) -\u003e Result\u003c(), error\u003e {\n    let stat = os.Stat(src)?\n\n    if !stat.Mode().IsRegular() {\n        return Err(fmt.Errorf(\"%s is not a regular file\", src))\n    }\n\n    let source = os.Open(src)?\n    defer source.Close()\n\n    let destination = os.Create(dst)?\n    defer destination.Close()\n\n    // ignore number of bytes copied\n    let _ = io.Copy(destination, source)?\n\n    Ok(())\n}\n```\n\n---\n\n## Guessing game example\n\nSmall game from the Rust book, implemented in Borgo.\n\nThings to note:\n\n- import packages from Go stdlib\n- `strconv.Atoi` returns an `Option\u003cint\u003e`\n- `Reader.ReadString` returns a `Result\u003cstring, error\u003e` (which can be unwrapped)\n\n```rust\nuse bufio\nuse fmt\nuse math.rand\nuse os\nuse strconv\nuse strings\n\nfn main() {\n    let reader = bufio.NewReader(os.Stdin)\n\n    let secret = rand.Intn(100) + 1\n\n    loop {\n        fmt.Println(\"Please input your guess.\")\n\n        let text = reader.ReadString('\\n').Unwrap()\n        let text = strings.TrimSpace(text)\n\n        let guess = match strconv.Atoi(text) {\n            Ok(n) =\u003e n,\n            Err(_) =\u003e continue,\n        }\n\n        fmt.Println(\"You guessed: \", guess)\n\n        if guess \u003c secret {\n            fmt.Println(\"Too small!\")\n        } else if guess \u003e secret {\n            fmt.Println(\"Too big!\")\n        } else {\n            fmt.Println(\"Correct!\")\n            break\n        }\n    }\n}\n```\n\n## Running locally\n\nBorgo is written in Rust, so you'll need `cargo`.\n\nTo compile all `.brg` files in the current folder:\n\n```bash\n$ cargo run -- build\n```\n\nThe compiler will generate `.go` files, which you can run as normal:\n\n```bash\n# generate a go.mod file if needed\n# $ go mod init foo\n$ go run .\n```\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborgo-lang%2Fborgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborgo-lang%2Fborgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborgo-lang%2Fborgo/lists"}