A modular collection of Go utility libraries covering ID generation, cryptography, notification delivery, IP geolocation, and other common backend needs.
English | 简体中文
- Multi-module design: 30+ independent Go modules (each with its own
go.mod, independently versioned) — import only the single module you need instead of the whole repository.
- Lightweight dependencies: several modules stick to the pure standard library (
sqlutil, netutil); every notify channel is implemented over bare HTTP with zero vendor SDKs.
- KRatos ecosystem friendly:
authorizer loads kratos-authz engines (noop / casbin / opa), jwtutil reuses the KRatos codec layer, and converter parses KRatos operation IDs directly.
- Protobuf-native:
fieldperm / fieldmaskutil trim protobuf messages field-by-field via protoreflect; trans / timeutil bridge protobuf well-known types.
- Batteries included: every module focuses on a single responsibility with a small API surface; most come with unit tests and usage examples.
Import paths are shown in full. Rows marked with 📦 are subpackages of their parent module (no standalone go.mod).
| Module |
Import Path |
Description |
Docs |
| id |
github.com/tx7do/go-utils/id |
ID generators: UUID v4/v7, Snowflake, Sonyflake, order IDs, and host machine IDs. |
docs |
| 📦 id/machineid |
(subpackage of id) |
Read the unique machine ID of most host OSes without admin privileges. |
docs |
| name_generator |
github.com/tx7do/go-utils/name_generator |
Name generator producing Chinese, English, and Japanese person names, plus game nicknames and item names. |
docs |
| code_generator |
github.com/tx7do/go-utils/code_generator |
Template-driven code generator with embedded and file-system template engines. |
— |
| rand |
github.com/tx7do/go-utils/rand |
Random utilities: global functions plus configurable Randomizer instances, with Seeder and a SHA-256 random source. |
docs |
| Module |
Import Path |
Description |
Docs |
| crypto |
github.com/tx7do/go-utils/crypto |
Encryption and signing: unified Cipher/Signer/Encryptor interfaces over AES, AES-GCM, RSA, ECDSA/ECDH, HMAC, and Chinese-national-standard SM algorithms. |
docs |
| password |
github.com/tx7do/go-utils/password |
Password hashing and verification: Bcrypt, Argon2, PBKDF2, SHA family, plus RSA/HMAC/ECDSA helpers and password policies. |
docs |
| jwtutil |
github.com/tx7do/go-utils/jwtutil |
JWT toolkit (built on golang-jwt/v5): parse, issue, refresh, verify, short-lived tokens, and extraction from HTTP requests. |
— |
| captcha |
github.com/tx7do/go-utils/captcha |
Highly customizable CAPTCHAs: digits, strings, arithmetic, Chinese characters, slider puzzles, click-text, and image rotation. |
docs |
| authorizer |
github.com/tx7do/go-utils/authorizer |
Authorization engine manager: loads kratos-authz engines (noop / casbin / opa) by config and injects role→(path, method) policy providers. |
docs |
| converter |
github.com/tx7do/go-utils/converter |
Permission-code converter mapping KRatos operation IDs or REST method+path to resource:action permission codes. |
docs |
| fieldperm |
github.com/tx7do/go-utils/fieldperm |
Field-level permission primitives: read/write trimming of protobuf messages from token claims, via protoreflect. |
docs |
| Module |
Import Path |
Description |
Docs |
| notify |
github.com/tx7do/go-utils/notify |
Unified multi-channel notification delivery: 40+ channels (Telegram, Slack, Discord, DingTalk, Feishu, WeCom, email, SMS, push, and more), all bare-HTTP with zero vendor SDKs. |
docs |
| mailer |
github.com/tx7do/go-utils/mailer |
Email sending over net/smtp: STARTTLS and implicit SSL/TLS, with ctx-aware connection timeouts. |
docs |
| eventbus |
github.com/tx7do/go-utils/eventbus |
In-process publish/subscribe event bus: sync/async/once subscriptions and composable handlers. |
docs |
| eventloop |
github.com/tx7do/go-utils/eventloop |
Single-goroutine sequential event loop: priority scheduling, frame-driven mode, and optional metrics. |
docs |
| Module |
Import Path |
Description |
Docs |
| netutil |
github.com/tx7do/go-utils/netutil |
Network security utilities: SSRF protection (blocked ranges, URL validation, resolution checks) and real client IP extraction. |
docs |
| geoip |
github.com/tx7do/go-utils/geoip |
IP geolocation backed by MaxMind GeoLite2, QQWry (纯真), and ip2region databases. |
docs |
| 📦 geoip/geolite |
(subpackage of geoip) |
Queries against MaxMind GeoLite2 mmdb databases. |
— |
| 📦 geoip/qqwry |
(subpackage of geoip) |
Queries against the QQWry IP database. |
— |
| 📦 geoip/ip2region |
(subpackage of geoip) |
Queries against the offline ip2region xdb database (v4/v6, with cache policies and a searcher pool). |
— |
| auditutil |
github.com/tx7do/go-utils/auditutil |
HTTP audit-log collection and tamper-proofing helpers: normalized client IPs, request metadata, signature helpers. |
docs |
| Module |
Import Path |
Description |
Docs |
| aggregator |
github.com/tx7do/go-utils/aggregator |
Data aggregation toolkit: parallel fetch and strongly-typed generic population, solving the N+1 query problem and DTO association backfill in microservices. |
docs |
| query_parser |
github.com/tx7do/go-utils/query_parser |
Query parser: turns API sort and filter expressions into SQL conditions. |
docs |
| ddl_parser |
github.com/tx7do/go-utils/ddl_parser |
Small SQL DDL parser focused on extracting CREATE TABLE definitions. |
docs |
| sqlutil |
github.com/tx7do/go-utils/sqlutil |
PostgreSQL lexical-level SQL auditing: literal masking and table extraction, pure standard library. |
docs |
| mapper |
github.com/tx7do/go-utils/mapper |
Type mapper: struct field mapping with enum conversion, for moving data between entities and DTOs. |
docs |
| copierutil |
github.com/tx7do/go-utils/copierutil |
Type converters for jinzhu/copier: time↔string, protobuf Timestamp/Duration, and other common conversions. |
— |
| Module |
Import Path |
Description |
Docs |
| doctext |
github.com/tx7do/go-utils/doctext |
Plain-text extraction from common document formats (txt/md/csv/json/xml/yaml/html, docx, pdf) for RAG ingestion and full-text search. |
docs |
| slug |
github.com/tx7do/go-utils/slug |
URL slug generation (built on gosimple/slug) with lowercase, case-sensitive, and English variants. |
— |
| Module |
Import Path |
Description |
Docs |
| translator |
github.com/tx7do/go-utils/translator |
Unified Translator interface and target-language definitions; vendor implementations live in submodules. |
docs |
| translator/alibaba |
github.com/tx7do/go-utils/translator/alibaba |
Alibaba Cloud machine translation client (200+ language pairs). |
docs |
| translator/baidu |
github.com/tx7do/go-utils/translator/baidu |
Baidu Translate API client. |
docs |
| translator/google |
github.com/tx7do/go-utils/translator/google |
Google Translate API client (three API versions). |
docs |
| translator/volc |
github.com/tx7do/go-utils/translator/volc |
Volcengine (ByteDance) translation client. |
docs |
| Module |
Import Path |
Description |
Docs |
| ossutil |
github.com/tx7do/go-utils/ossutil |
SDK-agnostic object-storage helpers: MIME/extension-to-bucket mapping and magic-number file type detection. |
docs |
| distlock |
github.com/tx7do/go-utils/distlock |
Unified distributed-lock abstraction over Redis and Etcd backends. |
docs |
| bank_card |
github.com/tx7do/go-utils/bank_card |
Bank card BIN lookup and validation: issuer identification and Luhn checksum checking. |
docs |
The following packages ship with the root module github.com/tx7do/go-utils (no standalone go.mod):
| Package |
Description |
Docs |
| trans |
Pointer/type conversion helpers (String, Int, etc. return pointers). |
— |
| timeutil |
Time layouts, formatting, diff, ranges, and protobuf Timestamp/Duration conversion. |
— |
| fieldmaskutil |
Protobuf FieldMask utilities: keep/clear fields by mask paths, with nested masking. |
docs |
| stringcase |
Naming-convention conversion: camelCase, PascalCase, snake_case, kebab-case. |
docs |
| stringutil |
String utilities: type conversion, random and crypto-secure random strings, JSON field replacement. |
docs |
| sliceutil |
Generic slice utilities (Filter, Map, etc.), inspired by JavaScript/Python. |
— |
| maputils |
Generic map utilities (Keys, Filter, etc.). |
— |
| structutil |
Iterate struct fields via reflection (name, value, tag). |
— |
| byteutil |
Integer/byte-slice conversions and binary read/write helpers. |
— |
| math |
Generic math helpers (sign function, Gaussian, etc.). |
— |
| pagination |
Pagination helpers (page offset calculation). |
— |
| dateutil |
Date helpers: align to day start/end boundaries and similar operations. |
— |
| cryptocurrency |
Cryptocurrency address format validation (BTC, BTG, DASH, and more). |
— |
| tls |
TLS certificate loading helpers for mutual-TLS setups. |
— |
| ioutil |
Simple file and path helpers. |
— |
MIT