go-admin-core

module
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2026 License: Apache-2.0

README ΒΆ

go-admin-core

Go Version License

δΈ­ζ–‡ζ–‡ζ‘£

✨ Core Features

πŸ“ Logger Module (Enterprise-Grade Logging Solution)
  • Async Logger - 45x performance boost (3,358ns β†’ 75ns), supports 100k+ QPS
  • Sampling Logger - 29x performance boost (3,357ns β†’ 116ns), intelligent frequency control
  • Sanitizer Logger - Auto-sanitize sensitive data (phone, password, email, etc.), compliance-ready
  • Logrus Adapter - Full Logrus ecosystem support with 50+ hooks available
  • Production-Ready Config - Built-in best practices (async + sampling + sanitization)
  • Concurrency Safe - Verified with Race Detector, zero data races
πŸš€ Other Components
  • Cache component (memory support)
  • Queue component (memory support)
  • Configuration management (multiple data sources)
  • Log writer (file rotation support)

Latest Version: Go 1.25.1 | 119 dependencies upgraded | 35 unit tests + 30+ performance benchmarks


πŸš€ Quick Start

Installation
go get -u github.com/go-admin-team/go-admin-core

System Requirements: Go 1.25.1 or higher

Basic Logging
package main

import "github.com/go-admin-team/go-admin-core/logger"

func main() {
    // Create Logrus logger instance
    log := logger.NewLogrusLogger(
        logger.WithPath("logs/app.log"),
        logger.WithLevel(logger.InfoLevel),
    )
    
    log.Log(logger.InfoLevel, "Application started")
    log.Fields(map[string]interface{}{
        "user_id": 12345,
        "action":  "login",
    }).Log(logger.InfoLevel, "User action")
}
High-Performance Async Logger
// Create async logger (recommended for high-concurrency scenarios)
baseLog := logger.NewLogrusLogger(
    logger.WithPath("logs/app.log"),
    logger.WithLevel(logger.InfoLevel),
)

asyncLog := logger.NewAsyncLogger(baseLog, logger.DefaultAsyncConfig)
defer asyncLog.(interface{ Close() error }).Close()

// 45x performance boost, only 75ns latency
asyncLog.Log(logger.InfoLevel, "High performance logging")
Sampling Logger (Frequency Control)
// Create sampling logger (auto-filter high-frequency duplicate logs)
samplingLog := logger.NewSamplingLogger(baseLog, logger.DefaultSamplingConfig)

// Only logs first 100 per second, then 1 out of every 100
for i := 0; i < 10000; i++ {
    samplingLog.Log(logger.InfoLevel, "High frequency log")
}
Sanitizer Logger (Data Security)
// Create sanitizer logger (auto-handle sensitive data)
sanitizerLog := logger.NewSanitizerLogger(baseLog, logger.DefaultSanitizerConfig)

sanitizerLog.Fields(map[string]interface{}{
    "phone":    "13812345678",  // Auto-sanitized β†’ "138****5678"
    "password": "secret123",    // Auto-sanitized β†’ "[REDACTED]"
    "email":    "user@example.com", // Auto-sanitized β†’ "u***@example.com"
}).Log(logger.InfoLevel, "User login")
// Combine: Sanitizer β†’ Sampling β†’ Async
sanitized := logger.NewSanitizerLogger(baseLog, logger.DefaultSanitizerConfig)
sampled := logger.NewSamplingLogger(sanitized, logger.DefaultSamplingConfig)
asyncLog := logger.NewAsyncLogger(sampled, logger.DefaultAsyncConfig)
defer asyncLog.(interface{ Close() error }).Close()

// 34x performance boost + data security + frequency control
asyncLog.Fields(map[string]interface{}{
    "phone":   "13812345678",
    "user_id": 12345,
}).Log(logger.InfoLevel, "Production logging")

πŸ“¦ Configuration Management

Read Configuration Files
package main

import "github.com/go-admin-team/go-admin-core/config"

func main() {
    source := config.FileSource("config.json")
    config.Setup(source, func() {
        // Configuration change callback
    })
}

πŸ“Š Performance Metrics

Feature Performance Boost Latency Memory Use Case
Async Logger 45x 75ns 120 B/op High-concurrency writes
Sampling Logger 29x 116ns 16 B/op High-frequency duplicate logs
Production Config 34x 98ns 149 B/op Production environments

Test Environment: Apple M1 Pro | Go 1.25.1 | Race Detector verified


πŸ§ͺ Test Coverage

# Run all tests
go test ./... -v

# Performance benchmarks
go test ./logger -bench=. -benchmem

# Concurrency safety check
go test ./logger -race

Test Results:

  • βœ… Unit Tests: 35/35 passed
  • βœ… Performance Benchmarks: 30+ passed
  • βœ… Concurrency Safety: Race Detector 0 warnings
  • βœ… Code Coverage: 85%+

πŸ“¦ Main Dependencies

github.com/casbin/casbin/v2         v2.135.0
github.com/gin-gonic/gin            v1.11.0
gorm.io/gorm                        v1.31.1
github.com/sirupsen/logrus          v1.9.3
golang.org/x/crypto                 v0.47.0

🀝 Contributing

We welcome Issues and Pull Requests!

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

πŸ“ License

Apache License 2.0 - See LICENSE file for details


  • go-admin - Gin + Vue + Element UI based RBAC system with separated frontend/backend
  • go-admin-ui - go-admin frontend project

⭐ Star History

If this project helps you, please give us a Star ⭐

Directories ΒΆ

Path Synopsis
Package config is an interface for dynamic configuration.
Package config is an interface for dynamic configuration.
encoder
Package encoder handles source encoding formats
Package encoder handles source encoding formats
loader
package loader manages loading from multiple sources
package loader manages loading from multiple sources
reader
Package reader parses change sets and provides config values
Package reader parses change sets and provides config values
secrets
Package secrets is an interface for encrypting and decrypting secrets
Package secrets is an interface for encrypting and decrypting secrets
secrets/box
Package box is an asymmetric implementation of config/secrets using nacl/box
Package box is an asymmetric implementation of config/secrets using nacl/box
secrets/secretbox
Package secretbox is a config/secrets implementation that uses nacl/secretbox to do symmetric encryption / verification
Package secretbox is a config/secrets implementation that uses nacl/secretbox to do symmetric encryption / verification
source
Package source is the interface for sources
Package source is the interface for sources
source/file
Package file is a file source.
Package file is a file source.
source/memory
Package memory is a memory source
Package memory is a memory source
Package errors provides a way to return detailed information for an RPC request error.
Package errors provides a way to return detailed information for an RPC request error.
internal module
observability
audit
Package log 已弃用
Package log 已弃用
observe
plugins
logger/logrus module
logger/zap module
sdk
api
pkg
pkg/captcha
Package captcha 已弃用
Package captcha 已弃用
pkg/casbin
Package mycasbin 已弃用
Package mycasbin 已弃用
pkg/jwtauth
Package jwtauth 已弃用
Package jwtauth 已弃用
pkg/response
Package response 已弃用
Package response 已弃用
tools
gorm/logger
Package logger 已弃用
Package logger 已弃用

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL