Kit module - github.com/Rehtt/Kit - Go Packages
Kit
π οΈ Go Universal Toolkit - A feature-rich, high-performance Go toolkit collection that provides simple, efficient, and practical tool modules to help developers quickly build high-quality projects.
β¨ Features
- π High Performance: Performance-optimized implementations
- π§© Modular Design: Independent modules, use as needed
- π§ Easy to Use: Simple API design, quick to get started
- π‘οΈ Type Safe: Full utilization of Go's type system
- π¦ Zero Dependencies: Most modules have no external dependencies
- π Actively Maintained: Active development and maintenance
π¦ Installation
# Latest version (recommended)
go get github.com/Rehtt/Kit@latest
# Compatible with older Go versions
go get github.com/Rehtt/Kit@go1.17
Requirements: Go 1.21+ (recommended) or Go 1.17+
π Quick Start
Web Server Example
package main
import (
"fmt"
"github.com/Rehtt/Kit/web"
"net/http"
)
func main() {
// Create web instance
app := web.New()
// Route definition
app.Get("/hello/:name", func(ctx *web.Context) {
name := ctx.GetUrlPathParam("name")
ctx.JSON(200, map[string]string{
"message": fmt.Sprintf("Hello, %s!", name),
"status": "success",
})
})
// Middleware support
app.Use(func(ctx *web.Context) {
ctx.Writer.Header().Set("X-Powered-By", "Kit")
ctx.Next()
})
// Start server
fmt.Println("Server starting on :8080")
http.ListenAndServe(":8080", app)
}
Logging Example
package main
import "github.com/Rehtt/Kit/log"
func main() {
// Basic logging
log.Info("Application started")
log.Error("Error occurred", "error", err)
// Structured logging
log.With("user_id", 123).Info("User logged in")
}
Cache Example
package main
import (
"github.com/Rehtt/Kit/cache"
"time"
)
func main() {
// Create cache instance
c := cache.New()
// Set cache
c.Set("key", "value", 5*time.Minute)
// Get cache
if value, ok := c.Get("key"); ok {
fmt.Println("Cache value:", value)
}
}
π§© Module Overview
Kit contains multiple independent modules that you can use as needed:
Core Modules
| Module | Description | Features |
|---|---|---|
| web | Lightweight web framework | Routing, middleware, JSON support |
| log | High-performance logging library | Structured logging, multiple levels, high performance |
| cache | Universal cache interface | In-memory cache, TTL support |
| db | Database tools | Condition building, query construction |
| http | HTTP client | Request wrapper, retry mechanism |
Utility Modules
| Module | Description | Features |
|---|---|---|
| file | File operation tools | File I/O, path handling |
| strings | String utilities | High-performance conversion, string processing |
| random | Random number generation | Random strings, number generation |
| util | General utilities | Snowflake ID, time tools |
| struct | Struct tools | Comparison, tag reading, conversion |
Data Structure Modules
| Module | Description | Features |
|---|---|---|
| maps | Thread-safe Map | Concurrent safe, high performance |
| queue | Queue implementation | Multiple queue types |
| slice | Slice utilities | Slice operations, functional programming |
| heap | Heap data structure | Priority queue, heap sort |
| expiredMap | Expiring Map | Auto expiration, memory management |
Network & System Modules
| Module | Description | Features |
|---|---|---|
| net | Network tools | Network detection, IP processing |
| host | Host information | System info retrieval |
| browser | Browser tools | Browser launch, control |
| wireguard | WireGuard tools | VPN configuration, management |
Other Utility Modules
| Module | Description | Features |
|---|---|---|
| i18n | Internationalization support | Multi-language, localization |
| yaml | YAML processing | Configuration file parsing |
| cli | Command line tools | CLI application building |
| generate | Code generation | Template generation, code generation |
| vt | Virtual terminal | Terminal control, color output |
| multiplex | Multiplexing | Connection multiplexing, load balancing |
π Documentation
Each module has detailed documentation and examples. Visit the corresponding module directory:
- π API Documentation
- π§ Usage Examples
- π Changelog
π οΈ Development Guide
Requirements
- Go 1.21+ (recommended)
- Git
Local Development
# Clone the project
git clone https://github.com/Rehtt/Kit.git
cd Kit
# Run tests
go test ./...
# Build project
go build ./...
Code Standards
- Follow Go official code standards
- Use
gofmtto format code - Write unit tests
- Add necessary documentation comments
π€ Contributing
We welcome and appreciate all forms of contributions!
How to Contribute
- π΄ Fork this project
- π§ Create a feature branch (
git checkout -b feature/amazing-feature) - πΎ Commit your changes (
git commit -m 'Add some amazing feature') - π€ Push to the branch (
git push origin feature/amazing-feature) - π Create a Pull Request
Contribution Guidelines
- Submit Issues to report bugs or suggest new features
- Create Pull Requests to contribute code
- Improve documentation and examples
- Share usage experiences and best practices
π Project Status
- β Actively Maintained: Regular updates and maintenance
- π Continuous Integration: Automated testing and building
- π Continuous Improvement: Ongoing optimization based on community feedback
- π‘οΈ Stable & Reliable: Proven in production environments
π Acknowledgments
Thanks to all developers who have contributed to the Kit project!
π License
This project is open source under the MIT License.
If this project helps you, please give us a βοΈ Star!
Made with β€οΈ by Rehtt