Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thatstoasty/gojo
Experiments in porting over Golang stdlib into Mojo.
https://github.com/thatstoasty/gojo
golang mojo mojo-lang reader-writer scanner
Last synced: 27 days ago
JSON representation
Experiments in porting over Golang stdlib into Mojo.
- Host: GitHub
- URL: https://github.com/thatstoasty/gojo
- Owner: thatstoasty
- License: mit
- Created: 2024-01-22T20:02:49.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-10-27T01:54:54.000Z (about 2 months ago)
- Last Synced: 2024-10-27T02:43:48.672Z (about 2 months ago)
- Topics: golang, mojo, mojo-lang, reader-writer, scanner
- Language: Mojo
- Homepage:
- Size: 2.12 MB
- Stars: 30
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mojo - gojo - Experiments in porting over Golang stdlib into Mojo. (🗂️ Libraries / Advent of Code 2023)
README
# gojo
Experiments in porting over Golang stdlib into Mojo.
It will not always be a 1:1 port, it's more so code inspired by the Golang stdlib and the Mojo community's code. This is not intended to be a full port, but rather a learning exercise and a way to experiment with Mojo's capabilities. Please feel free to contribute or use this as a starting point for your own projects! The codebase will remain in flux and will evolve with Mojo as future releases are created.
![Mojo Version](https://img.shields.io/badge/Mojo%F0%9F%94%A5-24.5-orange)
![Build Status](https://github.com/thatstoasty/gojo/actions/workflows/build.yml/badge.svg)
![Test Status](https://github.com/thatstoasty/gojo/actions/workflows/test.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)## Installation
1. First, you'll need to configure your `mojoproject.toml` file to include my Conda channel. Add `"https://repo.prefix.dev/mojo-community"` to the list of channels.
2. Next, add `gojo` to your project's dependencies by running `magic add gojo`.
3. Finally, run `magic install` to install in `gojo`. You should see the `.mojopkg` files in `$CONDA_PREFIX/lib/mojo/`.## What this includes
All of these packages are partially implemented and do not support unicode characters until Mojo supports them.
- `bufio`
- `Reader`: Buffered `io.Reader`
- `Scanner`: Scanner interface to read data via tokens.
- `bytes`
- `Buffer`: Buffer backed by `UnsafePointer[UInt8]`.
- `Reader`: Reader backed by `UnsafePointer[UInt8]`.
- `io`
- Traits: `Reader`, `Writer`, `Seeker`, `Closer`, `ReadWriter`, `ReadCloser`, `WriteCloser`, `ReadWriteCloser`, `ReadSeeker`, `ReadSeekCloser`, `WriteSeeker`, `ReadWriteSeeker`, `ReaderFrom`, `WriterReadFrom`, `WriterTo`, `ReaderWriteTo`, `ReaderAt`, `WriterAt`, `ByteReader`, `ByteScanner`, `ByteWriter`, `StringWriter`
- `Reader` and `Writer` wrapper functions.
- `FileWrapper`: `FileHandle` Wrapper Reader/Writer
- `STDOUT/STDERR` Writer (leveraging `libc`).
- `strings`
- `StringBuilder`: String builder for fast string concatenation.
- `Reader`: String reader.
- `fmt`
- Basic `sprintf` function.
- `syscall`
- External call wrappers for `libc` functions and types.
- `net`
- `Socket`: Wraps `FileDescriptor` and implements network specific functions.
- `FileDescriptor`: File Descriptor wrapper that implements `io.Writer`, `io.Reader`, and `io.Closer`.
- `Dial` and `Listen` functions. (for TCP and UDP only atm).## Usage
Please check out the `test`, `examples`, and `benchmarks` directories for usage of the various packages!
## Projects that use Gojo
### My projects
- `weave`: A collection of (ANSI-sequence aware) text reflow operations & algorithms. [Link to the project.](https://github.com/thatstoasty/weave)
- `mog`: Terminal text styling library. [Link to the project.](https://github.com/thatstoasty/mog)
- `stump`: Bound Logger library. [Link to the project.](https://github.com/thatstoasty/stump)
- `prism`: CLI Library. [Link to the project.](https://github.com/thatstoasty/prism)### Community projects
- `lightbug_http`: Simple and fast HTTP framework for Mojo! 🔥 [Link to the project.](https://github.com/saviorand/lightbug_http/tree/main)