ModularM
Modular2y ago
2 replies
toasty

Gojo: Experiments in porting over Golang stdlib into Mojo

https://github.com/thatstoasty/gojo/tree/main

This library is my attempt at porting over some modules and structs from Golang's stdlib. You can find the list below! Most of these topics were new to me when starting the port, so if you find bugs or opportunities for improvement feel free to drop some comments!

It's been a good learning opportunity for both Go and Mojo.

Modules

- 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 interfaces for Socket connections (for TCP only atm).
- Socket struct similar to Python's and a simple FileDescriptor struct.
Was this page helpful?