A lightweight and flexible core library for Go applications by DNT.
- Multiple configuration sources (YAML, JSON, ENV)
- Type-safe configuration access
- Dynamic configuration updates
- Configuration validation
- Environment variable support
- Multiple cache backends (Memory, Redis)
- TTL support
- Cache tags
- Bulk operations
- Automatic key expiration
- Multiple queue backends
- Message patterns (Pub/Sub, Work Queue, RPC)
- Dead letter queue
- Message retry
- Priority queue
- Multiple log levels
- Structured logging
- Output formatting
- Log rotation
- Context-aware logging
- Error wrapping
- Stack traces
- Error types
- HTTP error integration
- Error context
- Localization support
go get github.com/ducconit/gocore
import "github.com/ducconit/gocore/config"
func main() {
// Create configuration
cfg := config.New(
config.WithFile("config.yaml"),
config.WithEnv(),
)
// Access configuration
port := cfg.GetInt("server.port", 8080)
host := cfg.GetString("server.host", "localhost")
}
import "github.com/ducconit/gocore/cache"
func main() {
// Create cache
c := cache.NewRedisCache(
cache.WithRedisAddr("localhost:6379"),
)
// Use cache
c.Set("key", "value", 5*time.Minute)
val, err := c.Get("key")
}
import "github.com/ducconit/gocore/logger"
func main() {
// Create logger
log := logger.New(
logger.WithLevel(logger.InfoLevel),
logger.WithOutput("path/to/file.log"),
)
// Log messages
log.Info("Server starting", zap.String("port", "3000"))
}
import "github.com/ducconit/gocore/errors"
func main() {
// Create error
err := errors.NewWithCode(404, "user not found").
WithContext("user_id", 123)
// Handle error
if e, ok := err.(errors.Error); ok {
fmt.Printf("Code: %d, Message: %s\n", e.Code(), e.Message())
}
}
Detailed documentation for each package can be found in their respective directories:
- Fork the repository
- Create your 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
MIT License
For support, please open an issue in the GitHub repository.
Duke |