|
1 | 1 | # toolbox |
2 | 2 |
|
3 | | -[](https://pkg.go.dev/github.com/richardwilkes/toolbox) |
4 | | -[](https://goreportcard.com/report/github.com/richardwilkes/toolbox) |
| 3 | +[](https://pkg.go.dev/github.com/richardwilkes/toolbox/v2) |
| 4 | +[](https://goreportcard.com/report/github.com/richardwilkes/toolbox/v2) |
5 | 5 |
|
6 | | -Toolbox for Go. Contains a wide variety of packages I've found useful in my own projects over the years. |
| 6 | +Toolbox for Go. |
7 | 7 |
|
8 | | -> [!NOTE] |
9 | | -> This library already had a v1.x.y when Go modules were first introduced. Due to this, it doesn't follow the |
10 | | -> normal convention and instead treats its releases as if they are of the v0.x.y variety (i.e. it could introduce |
11 | | -> breaking API changes). Keep this in mind when deciding whether or not to use it. |
| 8 | +Contains a wide variety of code I've found useful in my own projects over the years. For cases where code exists to help |
| 9 | +use standard library code, the package has been named the same as the standard library one, but with a preceeding "x" |
| 10 | +(for extended). This allows both to be used in the same file without having to do import renaming. |
| 11 | + |
| 12 | +## Package Overview |
| 13 | + |
| 14 | +### Core Utilities |
| 15 | + |
| 16 | +- **`check`** - Enhanced testing utilities that wrap Go's standard testing interface with more informative error messages and convenient assertion methods. |
| 17 | + |
| 18 | +- **`errs`** - Structured error handling with stack traces, error chaining, and detailed error objects that provide source locations and nested causes for better debugging. |
| 19 | + |
| 20 | +- **`i18n`** - Internationalization support for applications, providing localization capabilities for user-facing text and messages. |
| 21 | + |
| 22 | +- **`notifier`** - Event notification system for implementing the observer pattern, allowing objects to register for and receive notifications about events. |
| 23 | + |
| 24 | +- **`tid`** - Thread-safe unique identifier generation using cryptographically secure random values encoded in base64. |
| 25 | + |
| 26 | +### Mathematical and Numerical |
| 27 | + |
| 28 | +- **`xmath`** - Extended mathematical functions with generic type constraints (e.g., `Numeric` interface) that work across integer and floating-point types. |
| 29 | + |
| 30 | +- **`num128`** - 128-bit integer arithmetic with signed (`Int`) and unsigned (`UInt`) types for high-precision calculations that exceed native Go integer limits. |
| 31 | + |
| 32 | +- **`fixed`** - Fixed-point decimal arithmetic for precise financial and monetary calculations, with separate packages for 64-bit (`fixed64`) and 128-bit (`fixed128`) precision. |
| 33 | + |
| 34 | +### Geometry and Graphics |
| 35 | + |
| 36 | +- **`geom`** - Generic geometric primitives including `Point[T]`, `Rect[T]`, `Size[T]`, `Line[T]`, `Matrix[T]`, and `Insets[T]` with type conversion utilities. |
| 37 | + |
| 38 | +- **`geom/poly`** - Provides polygon operations using fixed-point arithmetic for reliable geometric computations. |
| 39 | + |
| 40 | +- **`geom/visibility`** - 2D visibility polygon computation for line-of-sight calculations. |
| 41 | + |
| 42 | +### Data Structures and Collections |
| 43 | + |
| 44 | +- **`collection/bitset`** - Efficient bitset implementation for working with sets of bits. |
| 45 | + |
| 46 | +- **`collection/quadtree`** - Spatial data structure for efficient 2D range queries and collision detection. |
| 47 | + |
| 48 | +- **`collection/redblack`** - Generic red-black tree implementation providing balanced binary search tree functionality. |
| 49 | + |
| 50 | +### Extended Standard Library |
| 51 | + |
| 52 | +- **`xbytes`** - Extended byte manipulation utilities including BOM (Byte Order Mark) handling and buffer utilities. |
| 53 | + |
| 54 | +- **`xcrc64`** - Extended CRC64 checksum utilities for data integrity verification. |
| 55 | + |
| 56 | +- **`xcrypto`** - Cryptographic utilities including stream encryption/decryption helpers. |
| 57 | + |
| 58 | +- **`xfilepath`** - Extended file path utilities with filename manipulation, root detection, and cross-platform path splitting. |
| 59 | + |
| 60 | +- **`xflag`** - Enhanced command-line flag parsing with rich usage formatting, automatic version flags, and post-parse function handling. |
| 61 | + |
| 62 | +- **`xhash`** - Extended hashing utilities for creating consistent hash values across different data types. |
| 63 | + |
| 64 | +- **`xhttp`** - HTTP utilities including basic authentication, gzip handling, metadata management, file retrieval, and server helpers. |
| 65 | + |
| 66 | +- **`ximage`** - Image processing utilities with support for various image formats. |
| 67 | + |
| 68 | +- **`xio`** - Extended I/O utilities including BOM stripping, safe file closing, and specialized readers/writers. |
| 69 | + |
| 70 | +- **`xjson`** - Enhanced JSON handling utilities for parsing and marshaling with additional features. |
| 71 | + |
| 72 | +- **`xnet`** - Network utilities for address manipulation and network-related operations. |
| 73 | + |
| 74 | +- **`xos`** - Operating system utilities including application information, browser launching, filesystem operations, panic recovery, safe file handling, task queues, and user information. |
| 75 | + |
| 76 | +- **`xrand`** - Extended random number generation utilities for cryptographically secure randomness. |
| 77 | + |
| 78 | +- **`xreflect`** - Reflection utilities for working with Go's reflection API more effectively. |
| 79 | + |
| 80 | +- **`xruntime`** - Runtime utilities including detailed stack trace generation with source location information. |
| 81 | + |
| 82 | +- **`xslices`** - Enhanced slice manipulation utilities including column-based sorting and other advanced slice operations. |
| 83 | + |
| 84 | +- **`xslog`** - Enhanced structured logging with a "pretty" formatter that provides colorful output, stack trace formatting, and improved readability. |
| 85 | + |
| 86 | +- **`xstrings`** - String manipulation utilities including case conversion, text wrapping, natural sorting, emoji handling, capitalization, space collapsing, and various string processing functions. |
| 87 | + |
| 88 | +- **`xsync`** - Synchronization utilities extending Go's sync package with additional concurrent programming tools. |
| 89 | + |
| 90 | +- **`xterm`** - Terminal utilities for ANSI color codes, terminal detection, and formatted output with cross-platform compatibility. |
| 91 | + |
| 92 | +- **`xtime`** - Time manipulation utilities extending Go's time package with additional date/time functionality. |
| 93 | + |
| 94 | +- **`xunicode`** - Unicode utilities for advanced text processing and character manipulation. |
| 95 | + |
| 96 | +- **`xyaml`** - YAML processing utilities for parsing and marshaling YAML data with enhanced features. |
| 97 | + |
| 98 | +### Specialized Utilities |
| 99 | + |
| 100 | +- **`rate`** - Rate limiting with hierarchical limiters, where each limiter can be capped by its parent, useful for implementing tiered rate limiting. |
| 101 | + |
| 102 | +- **`softref`** - Soft reference implementation for memory management, allowing resources to be garbage collected when memory pressure occurs. |
| 103 | + |
| 104 | +### Command Line Tools |
| 105 | + |
| 106 | +- **`cmd/i18n`** - Command-line tool for extracting and managing internationalization strings from Go source code. |
| 107 | + |
| 108 | +All packages follow consistent patterns with use of Go generics for type safety where appropriate, comprehensive error handling with the `errs` package, and thorough testing with the `check` package. The "x" prefix convention allows seamless use alongside standard library packages without import conflicts. |
0 commit comments