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.
- 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. - Next, add
gojo
to your project's dependencies by runningmagic add gojo
. - Finally, run
magic install
to install ingojo
. You should see the.mojopkg
files in$CONDA_PREFIX/lib/mojo/
.
All of these packages are partially implemented and do not support unicode characters until Mojo supports them.
bufio
Reader
: Bufferedio.Reader
Scanner
: Scanner interface to read data via tokens.
bytes
Buffer
: Buffer backed byUnsafePointer[UInt8]
.Reader
: Reader backed byUnsafePointer[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
andWriter
wrapper functions.FileWrapper
:FileHandle
Wrapper Reader/WriterSTDOUT/STDERR
Writer (leveraginglibc
).
- Traits:
strings
StringBuilder
: String builder for fast string concatenation.Reader
: String reader.
fmt
- Basic
sprintf
function.
- Basic
syscall
- External call wrappers for
libc
functions and types.
- External call wrappers for
net
Socket
: WrapsFileDescriptor
and implements network specific functions.FileDescriptor
: File Descriptor wrapper that implementsio.Writer
,io.Reader
, andio.Closer
.Dial
andListen
functions. (for TCP and UDP only atm).
Please check out the test
, examples
, and benchmarks
directories for usage of the various packages!
weave
: A collection of (ANSI-sequence aware) text reflow operations & algorithms. Link to the project.mog
: Terminal text styling library. Link to the project.stump
: Bound Logger library. Link to the project.prism
: CLI Library. Link to the project.
lightbug_http
: Simple and fast HTTP framework for Mojo! 🔥 Link to the project.