Skip to content

ducconit/gocore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoCore

A lightweight and flexible core library for Go applications by DNT.

Features

Configuration Management

  • Multiple configuration sources (YAML, JSON, ENV)
  • Type-safe configuration access
  • Dynamic configuration updates
  • Configuration validation
  • Environment variable support

Caching System

  • Multiple cache backends (Memory, Redis)
  • TTL support
  • Cache tags
  • Bulk operations
  • Automatic key expiration

Message Queue

  • Multiple queue backends
  • Message patterns (Pub/Sub, Work Queue, RPC)
  • Dead letter queue
  • Message retry
  • Priority queue

Logging System

  • Multiple log levels
  • Structured logging
  • Output formatting
  • Log rotation
  • Context-aware logging

Error Handling

  • Error wrapping
  • Stack traces
  • Error types
  • HTTP error integration
  • Error context
  • Localization support

Installation

go get github.com/ducconit/gocore

Quick Start

Configuration

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")
}

Caching

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")
}

Logging

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"))
}

Error Handling

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())
    }
}

Documentation

Detailed documentation for each package can be found in their respective directories:

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License

Support

For support, please open an issue in the GitHub repository.

Contributors

ducconit
Duke

About

A lightweight and flexible core library for Go applications

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages