GoDev is a comprehensive Go development toolkit that provides essential utilities, integrations, and framework components for building robust applications. It simplifies common development tasks and accelerates project setup with pre-built, production-ready packages.
- ποΈ Database: Multi-database support (PostgreSQL, MySQL, SQL Server, Oracle) with query builder
- π Logging: Structured logging with Zap, file rotation, and HTTP request/response logging
- π Redis: Full-featured Redis client with pub/sub, chain operations, and JSON serialization
- π° RabbitMQ: Message queue integration with publisher/consumer patterns
- π Keycloak: Identity and access management integration
- π HTTP Server: Gin-based HTTP server with middleware support
- π‘ REST Client: Type-safe HTTP client with automatic JSON handling
- β° Scheduler: Cron job scheduler with timezone support
- ποΈ Framework: Application bootstrap with lifecycle management
- βοΈ Config: Configuration management with Viper, environment variables, and placeholders
- π οΈ Utils: Comprehensive utility functions (crypto, datetime, string, validation, etc.)
| Package | Description | README |
|---|---|---|
framework |
Application bootstrap with lifecycle management, service initialization, and graceful shutdown | π Read More |
config |
Configuration management with file loading, environment variables, and placeholder expansion | π Read More |
logger |
Structured logging with Zap, file rotation, and HTTP logging | π Read More |
| Package | Description | README |
|---|---|---|
database |
Multi-database abstraction with query builder, transactions, and bulk operations | π Read More |
redis |
Redis client with chain operations, pub/sub, and JSON serialization | π Read More |
rabbitmq |
RabbitMQ integration with publisher/consumer patterns | π Read More |
migration |
Database migration utilities | π Read More |
| Package | Description | README |
|---|---|---|
ginfw/server |
Gin HTTP server with graceful shutdown and lifecycle hooks | π Read More |
ginfw/middleware/httplogger |
HTTP request/response logging middleware | π Read More |
ginfw/middleware/ratelimit |
Rate limiting middleware with Allow/Wait modes | π Read More |
ginfw/middleware/timeout |
Request timeout middleware | π Read More |
rest |
Type-safe REST client with automatic JSON handling | π Read More |
| Package | Description | README |
|---|---|---|
keycloak |
Keycloak identity and access management client | π Read More |
scheduler |
Cron job scheduler with timezone support and graceful shutdown | π Read More |
| Package | Description | README |
|---|---|---|
utils |
Comprehensive utility functions (crypto, datetime, string, validation, file, json, money, random) | π Read More |
consts |
Common constants (content types, extensions, patterns) | π Read More |
types |
Shared type definitions | π Read More |
go get github.com/BevisDev/godev@latestpackage main
import (
"context"
"log"
"time"
"github.com/BevisDev/godev/database"
"github.com/BevisDev/godev/framework"
"github.com/BevisDev/godev/ginfw/server"
"github.com/BevisDev/godev/logger"
"github.com/BevisDev/godev/redis"
"github.com/gin-gonic/gin"
)
func main() {
ctx := context.Background()
// Initialize application with framework
bootstrap := framework.New(
// Logger
framework.WithLogger(&logger.Config{
IsProduction: false,
IsLocal: true,
DirName: "./logs",
Filename: "app.log",
}),
// Database
framework.WithDatabase(&database.Config{
DBType: database.Postgres,
Host: "localhost",
Port: 5432,
DBName: "mydb",
Username: "user",
Password: "password",
Timeout: 5 * time.Second,
}),
// Redis
framework.WithRedis(&redis.Config{
Host: "localhost",
Port: 6379,
Timeout: 5 * time.Second,
}),
// HTTP Server
framework.WithServer(&server.Config{
Port: "8080",
IsProduction: false,
Setup: func(r *gin.Engine) {
r.GET("/health", func(c *gin.Context) {
c.JSON(200, gin.H{"status": "ok"})
})
},
}),
)
// Run application (init, start, graceful shutdown)
if err := bootstrap.Run(ctx); err != nil {
log.Fatal(err)
}
}import "github.com/BevisDev/godev/database"
db, err := database.New(&database.Config{
DBType: database.Postgres,
Host: "localhost",
Port: 5432,
DBName: "mydb",
Username: "user",
Password: "password",
})
if err != nil {
log.Fatal(err)
}
defer db.Close()
// Query with builder
users, err := database.Builder[User](db).
From("users").
Where("age > ?", 18).
FindAll(ctx)import "github.com/BevisDev/godev/logger"
appLogger, _ := logger.New(&logger.Config{
IsProduction: true,
DirName: "./logs",
Filename: "app.log",
MaxSize: 100,
MaxBackups: 7,
MaxAge: 30,
})
appLogger.Info("state", "Application started")import "github.com/BevisDev/godev/redis"
cache, err := redis.New(&redis.Config{
Host: "localhost",
Port: 6379,
Timeout: 5 * time.Second,
})
if err != nil {
log.Fatal(err)
}
defer cache.Close()
// Chain operations
err = redis.With[User](cache).
Key("user:1").
Value(user).
Expire(10 * time.Second).
Set(ctx)import "github.com/BevisDev/godev/rest"
client := rest.New(
rest.WithTimeout(10 * time.Second),
rest.WithLogger(appLogger),
)
user, err := rest.NewRequest[*UserResponse](client).
URL("https://api.example.com/users/:id").
PathParams(map[string]string{"id": "1"}).
GET(ctx)- Go: 1.21 or higher
- Database Drivers (as needed):
- PostgreSQL:
go get github.com/lib/pq - MySQL:
go get github.com/go-sql-driver/mysql - SQL Server:
go get github.com/denisenkom/go-mssqldb - Oracle:
go get github.com/godror/godror@latest
- PostgreSQL:
GoDev follows a modular architecture where each package is independent and can be used standalone or integrated through the framework package:
βββββββββββββββββββββββββββββββββββββββββββ
β Framework (Bootstrap) β
β - Lifecycle Management β
β - Service Initialization β
β - Graceful Shutdown β
βββββββββββββββββββββββββββββββββββββββββββ
β
ββββ Database βββ Redis βββ RabbitMQ
β
ββββ Logger βββ REST Client βββ Scheduler
β
ββββ HTTP Server (Gin)
β
ββββ Middleware: Logger, RateLimit, Timeout
ββββ Routes & Handlers
Each package includes comprehensive documentation with examples:
- Framework - Application bootstrap and lifecycle
- Database - Database operations and query builder
- Logger - Structured logging
- Redis - Redis client and operations
- HTTP Server - Gin server setup
- REST Client - HTTP client utilities
- Config - Configuration management
- Scheduler - Cron job scheduling
- Utils - Utility functions
All packages include comprehensive unit tests:
# Run all tests
go test ./...
# Run tests for specific package
go test ./database/...
go test ./logger/...Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure:
- Code follows Go best practices
- Tests are included for new features
- Documentation is updated
- All tests pass
This project is licensed under the MIT License - see the LICENSE file for details.
GoDev is built on top of excellent open-source libraries:
- Gin - HTTP web framework
- Zap - Structured logging
- sqlx - Database extensions
- go-redis - Redis client
- Viper - Configuration management
- Cron - Job scheduling
For questions, issues, or contributions, please open an issue on GitHub.
Made with β€οΈ for the Go community