How irdaislakhuafa/go-sdk works
Project type and purpose
• This is a Go Software Development Kit (SDK): a collection of reusable Go packages (libraries) providing utilities for context management, error handling, cryptography, data structures, file I/O, database access, caching, logging, concurrency control, SMTP/email, string formatting, and more.
• It is not a running service or full-stack app, but an open-source toolkit that application developers import to accelerate common tasks in Go projects.
File structure
• Every top-level directory corresponds to an independent Go package:
• appcontext
• auth
• caches
• codes
• collections
• concurrency
• convert
• cryptography
• datastructure
• db
• errors
• files
• header
• language
• log
• operator
• querybuilder
• random
• smtp
• sorter
• storage
• strformat
• Each package ends in .go files and has associated _test.go files.
• Configuration files exist for the querybuilder/sqlc sub-tool, demonstrating code generation from SQL schemas.
README
• Confirms the SDK’s purpose: “code collection” for common Go development tasks.
• Documents each package’s functionality and external dependencies (e.g., zerolog, gomail, text/template).
• Points out extensibility (e.g., TODO to implement disk storage).
Main components & relationships
a. Core utility packages
• codes → errors (error codes inform error package)
• errors → any package needing standardized errors
• collections, datastructure, convert, operator, random, sorter → general-purpose utilities
• strformat, header, language → string & i18n helpers
b. Infrastructure packages
• db (MySQL, PostgreSQL, SQLite)
• caches (in-memory, SQLite)
• storage (MinIO, future disk)
• files → file system helpers
• querybuilder/sqlc → code generation layer on top of db
c. Security & auth
• cryptography (AES-GCM, Argon2, bcrypt, SHA256)
• auth/jwt → JSON Web Token generation & validation
d. Concurrency
• concurrency (goroutine pool, semaphore)
e. Communication
• smtp (gomail wrapper)
• log (zerolog wrapper)
f. appcontext
• Carries request-scoped data across all layers
• An application at the top importing “Go SDK”
• smtp → SMTP server
• log → external zerolog library
• cryptography.argon2 → node-argon2-compatible format (interoperability)
Architectural patterns & design principles
• Modular single-responsibility packages
• Clear layering: core utilities vs. infrastructure vs. security vs. communication
• Dependency inversion: high-level modules depend on abstractions in low-level (e.g., caches interface vs. memory/sqlite implementations)
• Extensibility points: storage disk implementation placeholder, querybuilder codegen