Solod provides a growing set of high-level packages similar to Go's stdlib, and a low-level package to help with C interop. For full API details, see the package documentation.
bufio • bytes • c • cmp • conc • crypto/crand • encoding/binary • encoding/hex • errors • flag • fmt • io • log/slog • maps • math • math/bits • math/rand • mem • net • net/netip • os • path • runtime • slices • strconv • strings • sync • testing • time • unicode • unicode/utf8 • uuid
Buffered I/O. Wraps an io.Reader or io.Writer with buffering and helpers for textual I/O. Based on Go's bufio package.
Functions:
NewReaderandNewReaderSizecreate a buffered reader.NewWriterandNewWriterSizecreate a buffered writer.NewReadWritercombines a Reader and Writer into a singleio.ReadWriter.NewScannercreates a scanner for token-based reading (lines, words, bytes, or custom split functions).ScanLines,ScanWords,ScanBytesandScanRunesare built-in split functions forScanner.
Types:
Readerwraps anio.Readerwith buffering.Writerwraps anio.Writerwith buffering.ReadWritercombines a Reader and Writer.Scannerreads tokens from anio.Readerusing aSplitFunc.
Byte slice operations. Offers an API similar to Go's bytes package, but with fewer features.
Functions:
Clonereturns a copy of a slice.CompareandEqualcompare two slices lexicographically.Containsreports whether a subslice is within a slice.Countcounts the number of non-overlapping instances of a subslice in a slice.Cutslices around the first instance of a separator.HasPrefixandHasSuffixreport whether a slice begins/ends with a prefix/suffix.IndexandIndexBytesearch for a subslice or byte within a slice.Joinconcatenates slices with a separator.Replacereplaces occurrences of a subslice within a slice.Runesconverts a byte slice to a rune slice.SplitandSplitNsplit a slice into subslices.Stringcreates a string from a byte slice.ToLowerandToUpperreturn a copy with all letters lowercased/uppercased.TrimLeft,TrimRightandTrimSpacetrim characters from a slice.TrimPrefixandTrimSuffixtrim a prefix/suffix from a slice.
Types:
Bufferis a variable-sized buffer of bytes withReadandWritemethods.Readerreads data from a byte slice.
Low-level C interop helpers for pointers, strings, and type information.
Functions:
AlignofandSizeofreturn the alignment and size of type T.Allocaallocates an array on the stack.Assertaborts with a message if a condition is false.Bytes,SliceandStringwrap C pointers to So types.CStringconverts a So string to a null-terminated C string.PtrAdd,PtrAsandPtrAtmanipulate pointers.ValandRawemit raw C code.Zeroreturns the zero value of type T.
Types:
Char, andConstCharrepresent a Cchartype.Int,UInt,Long,ULong, etc. represent numeric C types.
Comparing ordered values. Based on Go's cmp package.
Functions:
Comparereturns -1, 0, or +1 for two ordered values.Equalreports whether two comparable values are equal.Lessreports whether x is less than y.
Types:
Funcis a comparison functionfunc(a, b any) int.FuncForreturns the appropriate comparison function for type T.
Basic primitives for concurrent programming, backed by pthreads. Meant to be used in place of language-level concurrency features.
Chan[T] is a thread-safe FIFO channel, similar to Go's built-in chan T. It carries values by copy: a sender copies a value into the channel and a receiver copies one out.
NewChan[T]creates a new channel, either buffered or unbuffered (rendezvous).Chan.Sendcopies a value into the channel (blocks until delivered).Chan.Recvcopies a value out of the channel (blocks until a value or close).Chan.SendTimeoutsends with a deadline, returning a status; a zero duration makes it non-blocking.Chan.RecvTimeoutreceives with a deadline, returning the value and a status; a zero duration makes it non-blocking.Chan.Closecloses the channel.Chan.Freereleases the channel's resources.
Thread is a handle to a single OS thread running a func(any) any:
Golaunches a thread and returns a handle to it.Thread.Waitblocks until the thread terminates.Thread.Detachhands the thread's resources to the runtime.
Pool is a bounded pool of worker threads for tasks of type func(any):
NewPoolcreates a pool of workers and starts them.Pool.Gosubmits a task for execution.Pool.Waitblocks until all submitted tasks finish; the pool stays usable afterward.Pool.Freedrains queued tasks, joins the workers, and releases the pool.
Cryptographically secure random number generation.
Readfills a slice with cryptographically secure random bytes.Readeris a global instance of a cryptographically secure RNG.Textreturns a cryptographically random string using the base32 alphabet.
Translation between numbers and byte sequences. Based on Go's encoding/binary package.
Types:
ByteOrderspecifies how to convert byte slices into unsigned integers.AppendByteOrderspecifies how to append unsigned integers into a byte slice.LittleEndianandBigEndianimplementByteOrderandAppendByteOrder.
Hexadecimal encoding and decoding. Based on Go's encoding/hex package.
Functions:
EncodedLenandDecodedLenreturn the encoded/decoded length for n bytes.EncodeandDecodeencode to or decode from hexadecimal in place.AppendEncodeandAppendDecodeappend the encoded/decoded form to a slice.EncodeToStringandDecodeStringconvert between a byte slice and a hexadecimal string.Dumpreturns a hex dump of data inhexdump -Cformat.NewEncoderandNewDecoderwrap anio.Writer/io.Readerfor streaming encoding/decoding.NewDumperreturns a writer that hex-dumps everything written to it.
Types:
Encoderwrites hexadecimal characters to an underlyingio.Writer.Decoderreads and decodes hexadecimal characters from an underlyingio.Reader.Dumperwrites a hex dump of all data written to it.
Error creation from text messages.
New(text string) error- create a new error with the given message.
So only supports sentinel errors, which are defined at the package level using New.
Command-line flag parsing. Based on Go's flag package.
Functions:
BoolVar,IntVar,UintVar,Float64VarandStringVardefine typed flags.Vardefines a flag with a customValueimplementation.Parseparses command-line flags fromos.Args.Argsreturns the non-flag command-line arguments after parsing.
Types:
FlagSetrepresents a set of defined flags with its own error handling and output.Flagrepresents a single flag.Valueis the interface for custom flag values.
Formatted I/O with functions analogous to C's printf and scanf. Uses C format verbs (not Go verbs).
PrintandPrintlnwrite strings to standard output.Printfformats and writes to standard output.Sprintfformats and writes to a string.Fprintfformats and writes to anio.Writer.Scanfscans formatted text from standard input.Sscanfscans formatted text from a string.Fscanfscans formatted text from anio.Reader.
Since Print and Println only take string arguments, you'll usually want to use the built-in functions print and println instead.
Basic interfaces to I/O primitives. Offers an API similar to Go's io package, but with fewer features.
Functions:
CopyandCopyNcopy data from a reader to a writer.ReadAllandReadFullread data from a reader.
Types:
Reader,Writer, andCloserare basic concepts for anything that does I/O.LimitedReaderandSectionReaderimplement specialized readerss.Discardis a no-op writer.
Simplified structured logging, inspired by Go's log/slog package. Provides leveled, key-value logging with zero-allocation formatting.
Functions:
Newcreates a Logger from a Handler.SetDefaultandDefaultmanage the default logger.Debug,Info,Warn,Errorlog at the corresponding level using the default logger.String,Int,Float64,Bool,TimeandDurationcreate key-value attributes.
Types:
Loggerlogs messages through aHandler.TextHandlerformats log records astimestamp LEVEL message key=value ...lines.Recordholds a log event (time, level, message, attributes).Attris a key-value pair.Valueis a tagged union holding the value.Levelrepresents severity.
Generic hashmap similar to Go's built-in map[K]V, backed by a Robin Hood hash table with automatic grow.
Functions:
Newcreates a newMapwith a given allocator.
Types:
Mapis a generic hashmap withGet,Set, andDeletemethods.Iteris an iterator over a map's key-value pairs.
Mathematical functions and constants. Offers the same API as Go's math package.
Bit counting and manipulation functions. Offers the same API as Go's math/bits package.
Pseudo-random number generation. Based on Go's math/rand/v2 package.
Top-level functions use a global Rand with a PCG source seeded by runtime.Seed.
Functions:
Int,Int32,Int64return non-negative pseudo-random integers.Uint,Uint32,Uint64return pseudo-random unsigned integers.IntN,Int32N,Int64Nreturn non-negative pseudo-random integers in [0,n).UintN,Uint32N,Uint64Nreturn pseudo-random unsigned integers in [0,n).Float32andFloat64return pseudo-random floats in [0.0,1.0).
Types:
Sourceis an interface for a source of pseudo-randomuint64values.PCGis a PCG generator with 128 bits of internal state. ImplementsSource.Randwraps aSourceand provides the same methods as the top-level functions.
Memory allocation with a pluggable allocator interface.
Functions:
Alloc/Free- allocate/free a single value.AllocSlice/FreeSlice- allocate/free a slice.
Types:
Allocatorinterface - custom allocator support (Alloc,Realloc,Free).SystemAllocator- default allocator backed by Ccalloc/realloc/free.Arena- bump allocator backed by a fixed buffer (Alloc,Realloc,Reset).
Basic TCP, UDP, and Unix domain socket networking. There is no concurrent server support.
Functions:
ResolveTCPAddrresolves ahost:portstring to aTCPAddr;ResolveUDPAddrdoes the same for aUDPAddr;ResolveUnixAddrcarries a socket path into aUnixAddr.DialTCPconnects to a TCP address;ListenTCPannounces on a local one.DialUDPcreates a connected UDP socket (fixed peer,Read/Write);ListenUDPcreates an unconnected one (any peer,ReadFrom/WriteTo).DialUnixconnects to a Unix socket;ListenUnixannounces a stream listener;ListenUnixgrambinds an unconnected datagram socket.SplitHostPortsplits ahost:portaddress into aHostPort;JoinHostPortdoes the reverse into a caller buffer.
Types:
TCPAddris the address of a TCP endpoint.TCPConnis a TCP connection; implementsio.Readerandio.Writer.TCPListeneris a TCP listener; itsAcceptmethod returns the nextTCPConn.UDPAddris the address of a UDP endpoint.UDPConnis a UDP socket; connected (Read/Write) or unconnected (ReadFrom/WriteTo).UnixAddris the path of a Unix domain socket endpoint.UnixConnis a Unix socket; a connected stream/datagram (Read/Write) or an unconnected datagram (ReadFrom/WriteTo).UnixListeneris a Unix stream listener; itsAcceptmethod returns the nextUnixConn.
Small value types for IP addresses, address-port pairs, and CIDR prefixes. IPv6 zones are stored as numeric scope IDs, not as strings.
Functions:
AddrFrom4andAddrFrom16create anAddrfrom a fixed-size byte array.AddrFromSlicecreates anAddrfrom a 4- or 16-byte slice.ParseAddrandMustParseAddrparse an IP address from a string.AddrPortFromcreates anAddrPortfrom anAddrand port.ParseAddrPortandMustParseAddrPortparse an address-port pair from a string.PrefixFromcreates aPrefixfrom anAddrand bit length.ParsePrefixandMustParsePrefixparse a CIDR prefix from a string.
Types:
Addris an IPv4 or IPv6 address.AddrPortis an IP address and port number.Prefixis a CIDR prefix.
File I/O and filesystem operations. Offers an API similar to Go's os package, built on POSIX APIs.
Functions:
Create,Open,OpenFileopen files for reading and/or writing.ReadFileandWriteFileread or write an entire file.ReadDirreads a directory and returns its entries.StatandLstatreturn file information.Chmod,Chown,Lchown,Chtimeschange file attributes.Renamerenames (moves) a file.Removeremoves a file or empty directory.Mkdircreates a directory.TempDir,CreateTemp,MkdirTempwork with temporary files and directories.GetwdandChdirmanage the current working directory.Getenv,LookupEnv,SetenvandUnsetenvmanage environment variables.Getpid,Getppid,Getuid,Geteuid,Getgid,Getegidreturn process/user info.Exitterminates the program with the given status code.
Variables:
Argsholds the command-line arguments, starting with the program name.
Types:
Filerepresents an open file with methods for reading and writing data.FileInfodescribes a file (returned byStatandLstat).FileModerepresents a file's mode and permission bits.DirEntrydescribes an entry in a directory (returned byReadDir).
Utility routines for manipulating slash-separated paths. Based on Go's path package.
Basereturns the last element of a path.Cleanreturns the shortest equivalent path by lexical processing.Dirreturns all but the last element of a path.Extreturns the file name extension used by a path.IsAbsreports whether a path is absolute.Joinjoins path elements into a single path.Matchreports whether a name matches a shell pattern.Splitsplits a path into directory and file components.
Information about the environment where the program was compiled, and runtime utilities.
GOOSandGOARCHspecify the target operating system and architecture.Versionreturns So's compiler version (git commit hash or tag).Seedreturns a cryptographically secure random 64-bit seed.
Operations on slices:
MakeandMakeCapallocate a slice,Freedeallocates it.Appendappends elements to a heap slice, growing if needed.Extendappends another slice to a heap slice, growing if needed.Clonecreates a shallow copy of the slice.Equalreports whether two slices are equal.ContainsandIndexsearch for value in a slice.Min,MinFunc,MaxandMaxFuncreturn the minimum/maximum element.Sort,SortFuncandSortStableFuncsort slices.
Conversions between numbers and strings. Offers an API similar to Go's strconv package, but with fewer features.
ParseBoolandFormatBoolconvert bool ↔ string.Atoi,Itoa,ParseIntandFormatIntconvert signed integer ↔ string.ParseUintandFormatUintconvert unsigned integer ↔ string.ParseFloatandFormatFloatconvert float ↔ string.
String operations. Offers an API similar to Go's strings package, but with fewer features.
Functions:
Clonereturns a fresh copy of a string.Comparecompares two strings lexicographically.ContainsandContainsFuncreport whether a substring is within a string.Countcounts the number of non-overlapping instances of a substring in a string.Cutslices a string around a separator.FieldsandFieldsFuncsplit a string around whitespace or a predicate.HasPrefixandHasSuffixreport whether a string begins/ends with a prefix/suffix.IndexandIndexFuncsearch for a substring within a string.Joinconcatenates string slices with a separator.Repeatreturns a string consisting of count copies of a string.ReplaceandReplaceAllreplace occurrences of a substring within a string.SplitandSplitNsplit a string into substrings.ToLowerandToUpperreturn a copy with all letters lowercased/uppercased.Trim,TrimFuncandTrimSpacetrim characters from a string.TrimPrefixandTrimSuffixtrim a prefix/suffix from a string.
Types:
Builderefficiently builds a string, minimizing memory copying.Readerreads data from a string.
Basic synchronization primitives, backed by pthreads.
Mutex is a mutual exclusion lock:
Mutex.Initprepares the mutex for use, leaving it unlocked.Mutex.LockandMutex.Unlockacquire and release the lock.Mutex.TryLocktries to acquire the lock and reports whether it succeeded.Mutex.Freereleases the mutex's resources.
Cond is a condition variable tied to a *Mutex:
Cond.Initprepares the condition variable, guarded by the given mutex.Cond.Waitatomically unlocks the mutex and blocks until signaled, then re-locks.Cond.WaitForwaits likeCond.Waitbut gives up after a given duration.Cond.SignalandCond.Broadcastwake one or all waiting threads.Cond.Freereleases the condition variable's resources.
Once runs a function exactly once, even when called concurrently:
Once.Initprepares the once for use.Once.Doruns the given function on the first call only.Once.Freereleases the once's resources.
Minimal testing support, mirroring Go's testing package. Tests live in a package's test subdirectory and are run with the so test command; benchmarks live in a bench subdirectory and are run with so bench. See the testing guide for details.
Functions:
RunTestsruns a list of tests, prints per-test results, and exits non-zero on failure. It is called from the generated test runner.
Types:
Tis passed to each test to record failure and skip state.Testpairs a test name with its function.
Measuring and displaying time. Offers an API similar to Go's time package, but handles locations, formatting, and parsing differently.
Time is always stored as UTC internally. Formatting and parsing use C strftime/strptime verbs (e.g. %Y-%m-%d %H:%M:%S).
Constants:
UTC- zero offset (UTC).Nanosecond,Microsecond,Millisecond,Second,Minute,Hour- common durations.
Functions:
Nowreturns the current time in UTC (with monotonic clock reading).Datereturns the Time for a given year, month, day, hour, min, sec, nsec, and offset (seconds east of UTC).Unix,UnixMilli,UnixMicrocreate a Time from a Unix timestamp.SinceandUntilreturn the duration elapsed since or until a given time.Parseparses a time string per layout (strptime verbs) with a given offset, returning a Time.
Types:
Timerepresents an instant in time with nanosecond precision. Always UTC.Durationrepresents elapsed time as an int64 nanosecond count.CalDateis a date specified by year, month, and day.CalClockis a time of day specified by hour, minute, and second.Offsetrepresents a fixed offset from UTC in seconds.
Data and functions to test certain properties of Unicode code points. Offers an API similar to Go's unicode package, but with fewer Unicode features (no support for graphic characters, punctuation, symbols, etc.).
IsDigit,IsLetterandIsSpacecheck for different character classes.IsLower,IsUpperandIsTitlecheck for character case.ToLower,ToUpperandToTitlechange the character case.
Functions to convert between runes and UTF-8 byte sequences. Offers the same API as Go's unicode/utf8 package.
DecodeRuneandDecodeRuneInStringunpacks a UTF-8-encoded rune from a byte slice or a string.EncodeRunewrites a UTF-8-encoded rune into a byte slice.RuneCountandRuneCountInStringreturn the number of runes in a byte slice or a string.ValidStringreports whether a string consists entirely of valid UTF-8-encoded runes.
Generating and manipulating universally unique identifiers (UUIDs), as specified in RFC 9562. Random components are generated with a cryptographically secure RNG.
Constants:
UUIDLen- length of a canonical UUID string (36).
Functions:
Newreturns a new UUID using an algorithm suitable for most purposes (currentlyNewV4).NewV4returns a random version 4 UUID.NewV7returns a time-ordered version 7 UUID.NilandMaxreturn the Nil and Max UUIDs.ParseandMustParseparse a UUID from a string.
Types:
UUIDis a 128-bit universally unique identifier.