Skip to content

Experiments in porting over Golang stdlib into Mojo.

License

Notifications You must be signed in to change notification settings

thatstoasty/gojo

Repository files navigation

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 Build Status Test Status License: 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

Community projects

About

Experiments in porting over Golang stdlib into Mojo.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages