goconfig

package module
v0.12.13 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 69 Imported by: 4

README

go-config

Go Reference Go Report Card Tests

一个功能强大且易于使用的Go配置管理库,支持多种配置格式、智能发现、热更新和安全访问。为第三方开发者提供开箱即用的配置管理解决方案。

✨ 核心特性

  • 🔧 多格式支持 - 支持YAML、JSON、TOML等多种配置格式
  • 🔥 配置热更新 - 实时监听配置文件变化并自动重载
  • 🛡️ 安全访问 - 防止空指针异常的链式配置访问
  • 🎯 智能发现 - 自动发现和加载配置文件(支持多环境)
  • 🌍 多环境支持 - 内置9种环境类型,支持自定义环境注册
  • 📦 丰富模块 - 内置40+配置模块,覆盖常见应用场景
  • 🚀 零配置启动 - 开箱即用的默认配置
  • 🎨 链式API - 优雅的构建器模式API设计

🌍 环境与配置文件发现

内置环境类型
环境类型 常量 支持的配置文件后缀
开发环境 EnvDevelopment dev, develop, development
本地环境 EnvLocal local, localhost
测试环境 EnvTest test, testing, qa, sit
预发布环境 EnvStaging staging, stage, stg, pre, preprod, pre-prod, fat, gray, grey, canary
生产环境 EnvProduction prod, production, prd, release, live, online, master, main
调试环境 EnvDebug debug, debugging, dbg
演示环境 EnvDemo demo, demonstration, showcase, preview, sandbox
UAT环境 EnvUAT uat, acceptance, user-acceptance, beta
集成环境 EnvIntegration integration, int, ci, integration-test, integ
配置文件命名规则

配置文件命名格式:{prefix}-{env-suffix}.{ext}

例如,当 APP_ENV=local 且前缀为 gateway-xl 时,会按优先级查找:

  • gateway-xl-local.yaml
  • gateway-xl-local.yml
  • gateway-xl-localhost.yaml
  • ...
注册自定义环境

如果内置环境不满足需求,可以注册自定义环境:

package main

import goconfig "github.com/kamalyes/go-config"

func init() {
    // 注册自定义环境 "custom",支持后缀 "custom", "my-env", "myenv"
    // 配置文件可命名为: gateway-xl-custom.yaml, gateway-xl-my-env.yaml 等
    goconfig.RegisterEnvPrefixes("custom", "custom", "my-env", "myenv")
}
配置文件未找到时的错误提示

当配置文件未找到时,会输出详细的诊断信息:

❌ 未找到前缀为 'gateway-xl' 的配置文件
📍 搜索路径: resources
🌍 当前环境: custom-env
⚠️ 当前环境 'custom-env' 未在 DefaultEnvPrefixes 中注册
📋 已注册的环境及其后缀:
   - development: [dev develop development]
   - local: [local localhost]
   ...

💡 如需注册自定义环境,请在程序启动前注册:

   示例代码:
   func init() {
       goconfig.RegisterEnvPrefixes("custom-env", "custom-env", "custom-alias")
   }

🚀 快速开始

安装
go get github.com/kamalyes/go-config
基础使用 - 配置热更新
package main

import (
    "fmt"
    "time"
    
    goconfig "github.com/kamalyes/go-config"
    "github.com/kamalyes/go-config/pkg/gateway"
)

func main() {
    // 初始化HTTPServer配置
    config := gateway.DefaultHTTPServer()
    
    // 配置热更新回调
    hotReloadConfig := &goconfig.HotReloadConfig{
        Enabled: true,
        OnReloaded: func(oldConfig, newConfig interface{}) {
            fmt.Printf("配置已更新: %+v -> %+v\n", oldConfig, newConfig)
        },
        OnError: func(err error) {
            fmt.Printf("热更新错误: %v\n", err)
        },
    }
    
    // 创建并启动配置管理器
    manager := goconfig.NewConfigBuilder(config).
        WithConfigPath("config.yaml").
        WithEnvironment(goconfig.EnvDevelopment).
        WithHotReload(hotReloadConfig).
        MustBuildAndStart()
    
    defer manager.Stop()
    
    // 使用安全配置访问
    safeConfig := goconfig.SafeConfig(config)
    
    fmt.Printf("HTTP服务器启动在 %s:%d\n", 
        safeConfig.Host("localhost"), 
        safeConfig.Port(8080))
    
    fmt.Printf("启用HTTP: %v\n", 
        safeConfig.Field("EnableHttp").Bool(true))
    
    // 保持程序运行以观察热更新
    select {
    case <-time.After(time.Minute * 5):
        fmt.Println("程序退出")
    }
}
创建配置文件 config.yaml
# HTTP服务器配置 - 注意字段名使用横线格式
module-name: "my-app-server"
host: "0.0.0.0" 
port: 8080
grpc-port: 9090
read-timeout: 30
write-timeout: 30
idle-timeout: 60
max-header-bytes: 1048576
enable-http: true
enable-grpc: false
enable-tls: false
enable-gzip-compress: true
tls:
  cert-file: ""
  key-file: ""
  ca-file: ""
headers:
  x-custom-header: "my-app"
  x-version: "1.0.0"

现在修改配置文件,程序会自动检测变化并重载配置!

🌟 环境管理功能

  • 自动环境初始化 - 包导入时自动初始化,无需手动调用
  • 🎯 便捷判断函数 - 提供 IsDev(), IsProduction() 等直观的环境判断函数
  • 📊 环境级别管理 - 按重要程度对环境进行分级管理
  • 🔄 环境变更监听 - 支持环境变更回调机制
  • 🛠️ 自定义环境注册 - 灵活注册自定义环境类型
快速使用环境判断
import goconfig "github.com/kamalyes/go-config"

func main() {
    // 无需手动初始化,直接使用
    if goconfig.IsDev() {
        log.SetLevel(log.DebugLevel)
    } else if goconfig.IsProduction() {
        log.SetLevel(log.WarnLevel)
    }
    
    // 环境级别判断
    if goconfig.IsProductionLevel() {
        // 启用生产级别的监控和安全功能
        enableProductionFeatures()
    }
}

📖 详细使用说明请参考:环境管理器使用文档

🎯 支持的配置模块

类别 模块 描述
网关服务 Gateway, HTTP, GRPC 网关和服务配置
数据存储 MySQL, PostgreSQL, SQLite, Redis 数据库配置
中间件 CORS, 限流, JWT, 恢复 常用中间件配置
监控运维 Health, Metrics, Prometheus, Jaeger 监控和链路追踪
消息队列 Kafka, MQTT 消息系统配置
第三方服务 支付宝, 微信支付, 阿里云短信 第三方集成

📜 许可证

本项目采用 MIT 许可证


如果这个项目对你有帮助,请给我们一个 ⭐️

Documentation

Overview

* @Author: kamalyes [email protected] * @Date: 2025-11-12 15:00:00 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-12 15:00:00 * @FilePath: \go-config\callback_manager.go * @Description: 通用回调管理组件,提供统一的事件回调机制 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes [email protected] * @Date: 2025-11-12 16:00:00 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-12 16:00:00 * @FilePath: \go-config\config_builder.go * @Description: 配置管理器构建器,提供链式API和灵活的配置发现机制 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes [email protected] * @Date: 2025-11-27 09:30:00 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-27 09:30:00 * @FilePath: \go-config\config_unmarshaler.go * @Description: 通用配置反序列化工具 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes [email protected] * @Date: 2025-11-12 15:40:00 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-12 15:40:00 * @FilePath: \go-config\error_handler.go * @Description: 统一错误处理组件,提供分类错误处理和日志记录 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes [email protected] * @Date: 2025-11-12 15:30:00 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-22 17:08:23 * @FilePath: \go-config\hot_reload.go * @Description: 重构后的配置热更新模块,使用通用回调管理器 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes [email protected] * @Date: 2025-11-12 16:20:00 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-12 16:20:00 * @FilePath: \go-config\integrated_manager_refactored.go * @Description: 重构后的集成配置管理器,专注于核心管理功能 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

Index

Constants

View Source
const (
	EnvDevelopment EnvironmentType = "development" // 开发环境
	EnvTest        EnvironmentType = "test"        // 测试环境
	EnvStaging     EnvironmentType = "staging"     // 预发布环境
	EnvUAT         EnvironmentType = "uat"         // 用户验收测试环境
	EnvProduction  EnvironmentType = "production"  // 生产环境
	EnvLocal       EnvironmentType = "local"       // 本地环境
	EnvDebug       EnvironmentType = "debug"       // 调试环境
	EnvDemo        EnvironmentType = "demo"        // 演示环境
	EnvIntegration EnvironmentType = "integration" // 集成环境

	// 向后兼容的别名
	Dev  = EnvDevelopment
	Sit  = EnvTest
	Fat  = EnvStaging
	Uat  = EnvUAT
	Prod = EnvProduction

	DefaultEnv EnvironmentType = EnvDevelopment
)

定义有效的环境常量

Variables

View Source
var ContextHelper = ContextKeyHelper{}

创建全局上下文辅助工具实例

View Source
var DefaultConfigNames = []string{"config", "application", "app", "gateway", "service"}

DefaultConfigNames 默认配置文件名

View Source
var DefaultEnvPrefixes = map[EnvironmentType][]string{
	EnvDevelopment: {"dev", "develop", "development"},
	EnvLocal:       {"local", "localhost"},
	EnvTest:        {"test", "testing", "qa", "sit"},
	EnvStaging:     {"staging", "stage", "stg", "pre", "preprod", "pre-prod", "fat", "gray", "grey", "canary"},
	EnvProduction:  {"prod", "production", "prd", "release", "live", "online", "master", "main"},
	EnvDebug:       {"debug", "debugging", "dbg"},
	EnvDemo:        {"demo", "demonstration", "showcase", "preview", "sandbox"},
	EnvUAT:         {"uat", "acceptance", "user-acceptance", "beta"},
	EnvIntegration: {"integration", "int", "ci", "integration-test", "integ"},
}

DefaultEnvPrefixes 全局环境前缀映射(统一定义,避免重复) 覆盖常见的环境命名约定,支持多种风格:短名、全名、连字符等

View Source
var DefaultSupportedExtensions = []string{".yaml", ".yml", ".json", ".toml", ".properties"}

DefaultSupportedExtensions 默认支持的配置文件扩展名

Functions

func ClearGlobalContextManager added in v0.7.1

func ClearGlobalContextManager()

ClearGlobalContextManager 清理全局上下文管理器(主要用于测试)

func DisableAutoLog added in v0.7.0

func DisableAutoLog()

DisableAutoLog 禁用自动美化日志输出(便捷函数)

func EnableAutoLog added in v0.7.0

func EnableAutoLog()

EnableAutoLog 启用自动美化日志输出(便捷函数)

func FlexibleMatchName added in v0.11.1

func FlexibleMatchName(mapKey, fieldName string) bool

FlexibleMatchName 灵活的键名匹配函数 支持多种命名约定之间的自动转换

匹配策略(按优先级): 1. 直接匹配(快速路径) 2. 大小写不敏感匹配 3. kebab-case 转 snake_case 4. camelCase/PascalCase 转 snake_case

参数:

mapKey: 配置文件中的键名(可能是 kebab-case、camelCase 等)
fieldName: 结构体字段的 mapstructure 标签名(通常是 snake_case)

返回:

bool: 是否匹配成功

func ForceLogConfigChange added in v0.7.0

func ForceLogConfigChange(event CallbackEvent, newConfig interface{})

ForceLogConfigChange 强制记录配置变更(忽略自动日志开关)

func ForceLogConfigError added in v0.7.0

func ForceLogConfigError(event CallbackEvent)

ForceLogConfigError 强制记录配置错误(忽略自动日志开关)

func ForceLogEnvChange added in v0.7.0

func ForceLogEnvChange(oldEnv, newEnv EnvironmentType)

ForceLogEnvChange 强制记录环境变更(忽略自动日志开关)

func GetConfigAs added in v0.8.0

func GetConfigAs[T any](icm *IntegratedConfigManager) (*T, error)

GetConfigAs 获取指定类型的配置

func GetConfigFromContext added in v0.7.0

func GetConfigFromContext(ctx context.Context) (interface{}, bool)

GetConfigFromContext 从上下文中获取配置信息

func GetCurrentEnvironmentLevel added in v0.12.4

func GetCurrentEnvironmentLevel() int

GetCurrentEnvironmentLevel 获取当前环境级别

func GetEnvPrefixes added in v0.12.4

func GetEnvPrefixes(env EnvironmentType) []string

GetEnvPrefixes 获取指定环境的前缀列表

func GetEnvironmentLevel added in v0.12.4

func GetEnvironmentLevel(env EnvironmentType) int

GetEnvironmentLevel 获取环境级别(用于比较环境的重要程度) 数字越小表示环境级别越高(生产环境最高)

func GetMetadataFromContext added in v0.7.0

func GetMetadataFromContext(ctx context.Context) (map[string]interface{}, bool)

GetMetadataFromContext 从上下文中获取元数据

func IsAnyOf added in v0.12.4

func IsAnyOf(envs ...EnvironmentType) bool

IsAnyOf 判断当前环境是否为指定环境类型中的任意一种 envs: 要检查的环境类型列表

func IsAutoLogEnabled added in v0.7.0

func IsAutoLogEnabled() bool

IsAutoLogEnabled 检查是否开启了自动日志输出

func IsDebug added in v0.12.4

func IsDebug() bool

IsDebug 判断当前环境是否为调试环境

func IsDemo added in v0.12.4

func IsDemo() bool

IsDemo 判断当前环境是否为演示环境

func IsDev added in v0.12.4

func IsDev() bool

IsDev 判断当前环境是否为开发环境

func IsDevelopmentLevel added in v0.12.4

func IsDevelopmentLevel() bool

IsDevelopmentLevel 判断当前环境是否为开发级别

func IsEnvironment added in v0.12.4

func IsEnvironment(env EnvironmentType) bool

IsEnvironment 通用环境判断函数 env: 要检查的环境类型

func IsIntegration added in v0.12.4

func IsIntegration() bool

IsIntegration 判断当前环境是否为集成环境

func IsLocal added in v0.12.4

func IsLocal() bool

IsLocal 判断当前环境是否为本地环境

func IsProduction added in v0.12.4

func IsProduction() bool

IsProduction 判断当前环境是否为生产环境

func IsProductionLevel added in v0.12.4

func IsProductionLevel() bool

IsProductionLevel 判断当前环境是否为生产级别

func IsStaging added in v0.12.4

func IsStaging() bool

IsStaging 判断当前环境是否为预发布环境

func IsTest added in v0.12.4

func IsTest() bool

IsTest 判断当前环境是否为测试环境

func IsTestingLevel added in v0.12.4

func IsTestingLevel() bool

IsTestingLevel 判断当前环境是否为测试级别

func IsUAT added in v0.12.4

func IsUAT() bool

IsUAT 判断当前环境是否为用户验收测试环境

func ListAllEnvPrefixes added in v0.12.4

func ListAllEnvPrefixes() map[EnvironmentType][]string

ListAllEnvPrefixes 列出所有已注册的环境前缀

func LogConfigChange added in v0.7.0

func LogConfigChange(event CallbackEvent, newConfig interface{})

LogConfigChange 记录配置变更 - 全局函数

func LogConfigError added in v0.7.0

func LogConfigError(event CallbackEvent)

LogConfigError 记录配置错误 - 全局函数

func LogEnvChange added in v0.7.0

func LogEnvChange(oldEnv, newEnv EnvironmentType)

LogEnvChange 记录环境变更 - 全局函数

func MustGetConfigAs added in v0.8.0

func MustGetConfigAs[T any](icm *IntegratedConfigManager) *T

MustGetConfigAs 必须成功获取指定类型的配置

func RegisterEnvPrefixes added in v0.12.4

func RegisterEnvPrefixes(env EnvironmentType, prefixes ...string)

RegisterEnvPrefixes 注册自定义环境前缀(包级别便捷函数) 内部调用 GetGlobalEnvManager().RegisterEnvironment(),保持逻辑统一 示例:

func init() {
    goconfig.RegisterEnvPrefixes("custom", "custom", "my-env", "myenv")
}

func SetAutoLogEnabled added in v0.7.0

func SetAutoLogEnabled(enabled bool)

SetAutoLogEnabled 设置是否自动开启美化日志输出

func SetContextKey added in v0.7.0

func SetContextKey(options *ContextKeyOptions)

SetContextKey 设置上下文键 options: 指定的上下文键选项,如果为 nil,将使用默认值

func SetCurrentEnvironment added in v0.12.4

func SetCurrentEnvironment(env EnvironmentType)

SetCurrentEnvironment 设置当前环境类型(便捷函数)

func SetGlobalBuilderFactory added in v0.10.0

func SetGlobalBuilderFactory(factory *BuilderFactory)

SetGlobalBuilderFactory 设置全局构建器工厂

func SetGlobalConfigFormatter added in v0.7.0

func SetGlobalConfigFormatter(cf *ConfigFormatter)

SetGlobalConfigFormatter 设置全局配置格式化器

func SetGlobalConfigLogger added in v0.7.0

func SetGlobalConfigLogger(logger *ConfigLogger)

SetGlobalConfigLogger 设置全局配置日志器

func SetGlobalErrorHandler added in v0.10.0

func SetGlobalErrorHandler(handler ErrorHandler)

SetGlobalErrorHandler 设置全局错误处理器

func UnmarshalWithFlexibleNaming added in v0.11.1

func UnmarshalWithFlexibleNaming(v *viper.Viper, target interface{}) error

UnmarshalWithFlexibleNaming 使用灵活的命名匹配策略反序列化配置 支持的转换场景: 1. 直接匹配(大小写敏感) 2. 大小写不敏感匹配 3. kebab-case (service-name) -> snake_case (service_name) 4. camelCase (serviceName) -> snake_case (service_name) 5. PascalCase (ServiceName) -> snake_case (service_name)

参数:

v: Viper 实例
target: 目标配置结构体指针

返回:

error: 反序列化错误

func UnmarshalWithKebabToSnake added in v0.11.1

func UnmarshalWithKebabToSnake(v *viper.Viper, target interface{}) error

UnmarshalWithKebabToSnake 专门用于 kebab-case 到 snake_case 的转换 这是 UnmarshalWithFlexibleNaming 的简化版本,主要用于 YAML 配置

参数:

v: Viper 实例
target: 目标配置结构体指针

返回:

error: 反序列化错误

func WithGlobalConfig added in v0.7.0

func WithGlobalConfig(ctx context.Context) context.Context

WithGlobalConfig 使用全局上下文管理器将配置添加到上下文中

Types

type BuilderFactory added in v0.10.0

type BuilderFactory struct {
	// contains filtered or unexported fields
}

BuilderFactory 构建器工厂

func GetGlobalBuilderFactory added in v0.10.0

func GetGlobalBuilderFactory() *BuilderFactory

GetGlobalBuilderFactory 获取全局构建器工厂

func NewBuilderFactory added in v0.10.0

func NewBuilderFactory() *BuilderFactory

NewBuilderFactory 创建新的构建器工厂

func (*BuilderFactory) CreateBuilder added in v0.10.0

func (f *BuilderFactory) CreateBuilder(config interface{}) interface{}

CreateBuilder 创建配置构建器 注意:由于Go泛型限制,推荐直接使用 NewConfigBuilder

func (*BuilderFactory) SetDefaults added in v0.10.0

func (f *BuilderFactory) SetDefaults(options ConfigBuilderOptions) *BuilderFactory

SetDefaults 设置默认选项

type CallbackEvent added in v0.7.0

type CallbackEvent struct {
	Type        CallbackType           `json:"type"`        // 事件类型
	Timestamp   time.Time              `json:"timestamp"`   // 事件时间
	Source      string                 `json:"source"`      // 事件源(文件路径、环境变量名等)
	OldValue    interface{}            `json:"old_value"`   // 旧值
	NewValue    interface{}            `json:"new_value"`   // 新值
	Environment EnvironmentType        `json:"environment"` // 当前环境
	Error       error                  `json:"error"`       // 错误信息(仅错误回调)
	Metadata    map[string]interface{} `json:"metadata"`    // 附加元数据
	ConfigPath  string                 `json:"config_path"` // 配置文件路径
	Duration    time.Duration          `json:"duration"`    // 事件处理耗时
}

CallbackEvent 回调事件结构

func CreateErrorEvent added in v0.10.0

func CreateErrorEvent(source string, err error) CallbackEvent

CreateErrorEvent 创建错误事件的辅助函数

func CreateEvent added in v0.10.0

func CreateEvent(eventType CallbackType, source string, oldValue, newValue interface{}) CallbackEvent

CreateEvent 创建回调事件的辅助函数

func (*CallbackEvent) GetMetadata added in v0.10.0

func (e *CallbackEvent) GetMetadata(key string) (interface{}, bool)

GetMetadata 获取事件元数据

func (*CallbackEvent) WithMetadata added in v0.10.0

func (e *CallbackEvent) WithMetadata(key string, value interface{}) *CallbackEvent

WithMetadata 为事件添加元数据

type CallbackFunc added in v0.7.0

type CallbackFunc func(ctx context.Context, event CallbackEvent) error

CallbackFunc 回调函数类型

type CallbackManager added in v0.7.0

type CallbackManager interface {
	// RegisterCallback 注册回调函数
	RegisterCallback(callback CallbackFunc, options CallbackOptions) error

	// UnregisterCallback 注销回调函数
	UnregisterCallback(id string) error

	// TriggerCallbacks 触发回调函数
	TriggerCallbacks(ctx context.Context, event CallbackEvent) error

	// ListCallbacks 列出所有已注册的回调
	ListCallbacks() []string

	// ClearCallbacks 清空所有回调
	ClearCallbacks()

	// HasCallback 检查是否存在指定ID的回调
	HasCallback(id string) bool
}

CallbackManager 回调管理器接口 提供统一的回调注册、注销和执行机制

func NewCallbackManager added in v0.10.0

func NewCallbackManager() CallbackManager

NewCallbackManager 创建新的回调管理器

type CallbackOptions added in v0.7.0

type CallbackOptions struct {
	ID       string                   // 回调的唯一标识符
	Types    []CallbackType           // 监听的事件类型
	Priority int                      // 优先级(越小越优先)
	Async    bool                     // 是否异步执行
	Timeout  time.Duration            // 超时时间
	Retry    int                      // 重试次数
	Filter   func(CallbackEvent) bool // 事件过滤器
}

CallbackOptions 回调选项配置

func DefaultCallbackOptions added in v0.10.0

func DefaultCallbackOptions() CallbackOptions

DefaultCallbackOptions 默认回调选项

type CallbackType added in v0.7.0

type CallbackType string

CallbackType 回调类型枚举

const (
	CallbackTypeConfigChanged CallbackType = "config_changed" // 配置变更
	CallbackTypeReloaded      CallbackType = "reloaded"       // 重新加载完成
	CallbackTypeError         CallbackType = "error"          // 错误事件
	CallbackTypeStarted       CallbackType = "started"        // 启动事件
	CallbackTypeStopped       CallbackType = "stopped"        // 停止事件
	CallbackTypeEnvironment   CallbackType = "environment"    // 环境变更
	CallbackTypeValidation    CallbackType = "validation"     // 配置验证
	CallbackTypeFileChanged   CallbackType = "file_changed"   // 文件变更
	CallbackTypeEnvVarChanged CallbackType = "envvar_changed" // 环境变量变更
)

type CommonCallbackManager added in v0.10.0

type CommonCallbackManager struct {
	// contains filtered or unexported fields
}

CommonCallbackManager 通用回调管理器实现

func (*CommonCallbackManager) ClearCallbacks added in v0.10.0

func (cm *CommonCallbackManager) ClearCallbacks()

ClearCallbacks 清空所有回调

func (*CommonCallbackManager) GetCallbackCount added in v0.10.0

func (cm *CommonCallbackManager) GetCallbackCount() int

GetCallbackCount 获取回调总数

func (*CommonCallbackManager) GetCallbackInfo added in v0.10.0

func (cm *CommonCallbackManager) GetCallbackInfo(id string) (CallbackOptions, bool)

GetCallbackInfo 获取回调信息(用于调试)

func (*CommonCallbackManager) HasCallback added in v0.10.0

func (cm *CommonCallbackManager) HasCallback(id string) bool

HasCallback 检查是否存在指定ID的回调

func (*CommonCallbackManager) ListCallbacks added in v0.10.0

func (cm *CommonCallbackManager) ListCallbacks() []string

ListCallbacks 列出所有已注册的回调

func (*CommonCallbackManager) RegisterCallback added in v0.10.0

func (cm *CommonCallbackManager) RegisterCallback(callback CallbackFunc, options CallbackOptions) error

RegisterCallback 注册回调函数

func (*CommonCallbackManager) TriggerCallbacks added in v0.10.0

func (cm *CommonCallbackManager) TriggerCallbacks(ctx context.Context, event CallbackEvent) error

TriggerCallbacks 触发回调函数

func (*CommonCallbackManager) UnregisterCallback added in v0.10.0

func (cm *CommonCallbackManager) UnregisterCallback(id string) error

UnregisterCallback 注销回调函数

type ConfigBuilder added in v0.10.0

type ConfigBuilder[T any] interface {
	// WithConfigPath 设置配置文件路径
	WithConfigPath(path string) ConfigBuilder[T]

	// WithSearchPath 设置配置文件搜索路径
	WithSearchPath(path string) ConfigBuilder[T]

	// WithEnvironment 设置运行环境
	WithEnvironment(env EnvironmentType) ConfigBuilder[T]

	// WithPrefix 设置配置文件名前缀
	WithPrefix(prefix string) ConfigBuilder[T]

	// WithPattern 设置文件匹配模式
	WithPattern(pattern string) ConfigBuilder[T]

	// WithHotReload 启用配置热重载功能
	WithHotReload(config *HotReloadConfig) ConfigBuilder[T]

	// WithContext 设置上下文配置选项
	WithContext(options *ContextKeyOptions) ConfigBuilder[T]

	// WithErrorHandler 设置错误处理器
	WithErrorHandler(handler ErrorHandler) ConfigBuilder[T]

	// Build 构建配置管理器
	Build() (*IntegratedConfigManager, error)

	// BuildAndStart 构建并启动配置管理器
	BuildAndStart(ctx ...context.Context) (*IntegratedConfigManager, error)

	// MustBuildAndStart 构建并启动配置管理器(失败时panic)
	MustBuildAndStart(ctx ...context.Context) *IntegratedConfigManager
}

ConfigBuilder 配置构建器接口

func NewConfigBuilder added in v0.10.0

func NewConfigBuilder[T any](config *T) ConfigBuilder[T]

NewConfigBuilder 创建新的配置构建器

func NewManager added in v0.8.0

func NewManager[T any](config *T) ConfigBuilder[T]

NewManager 创建新的配置管理器构建器(简化API)

type ConfigBuilderOptions added in v0.10.0

type ConfigBuilderOptions struct {
	ConfigPath      string             `json:"config_path"`       // 配置文件路径
	SearchPath      string             `json:"search_path"`       // 搜索路径
	Environment     EnvironmentType    `json:"environment"`       // 环境类型
	ConfigPrefix    string             `json:"config_prefix"`     // 配置前缀
	Pattern         string             `json:"pattern"`           // 匹配模式
	HotReloadConfig *HotReloadConfig   `json:"hot_reload_config"` // 热重载配置
	ContextOptions  *ContextKeyOptions `json:"context_options"`   // 上下文选项
	ErrorHandler    ErrorHandler       `json:"-"`                 // 错误处理器(不序列化)
}

ConfigBuilderOptions 配置构建器选项

type ConfigContext added in v0.7.0

type ConfigContext struct {
	Environment EnvironmentType        `json:"environment"` // 当前环境
	Config      interface{}            `json:"config"`      // 配置对象
	Metadata    map[string]interface{} `json:"metadata"`    // 元数据
	CreatedAt   time.Time              `json:"created_at"`  // 创建时间
	UpdatedAt   time.Time              `json:"updated_at"`  // 更新时间
}

ConfigContext 配置上下文

type ConfigDiscovery added in v0.7.0

type ConfigDiscovery struct {
	// 支持的配置文件扩展名,按优先级排序
	SupportedExtensions []string
	// 默认配置文件名(不含扩展名)
	DefaultNames []string
	// 环境特定的配置文件前缀
	EnvPrefixes map[EnvironmentType][]string
}

ConfigDiscovery 配置文件发现器

func GetGlobalConfigDiscovery added in v0.7.0

func GetGlobalConfigDiscovery() *ConfigDiscovery

GetGlobalConfigDiscovery 获取全局配置发现器

func NewConfigDiscovery added in v0.7.0

func NewConfigDiscovery() *ConfigDiscovery

NewConfigDiscovery 创建配置文件发现器

func (*ConfigDiscovery) CreateDefaultConfigFile added in v0.7.0

func (cd *ConfigDiscovery) CreateDefaultConfigFile(searchPath string, env EnvironmentType, configType string) (*ConfigFileInfo, error)

CreateDefaultConfigFile 创建默认配置文件

func (*ConfigDiscovery) DiscoverConfigFiles added in v0.7.0

func (cd *ConfigDiscovery) DiscoverConfigFiles(searchPath string, env EnvironmentType) ([]*ConfigFileInfo, error)

DiscoverConfigFiles 在指定目录中发现配置文件

func (*ConfigDiscovery) FindBestConfigFile added in v0.7.0

func (cd *ConfigDiscovery) FindBestConfigFile(searchPath string, env EnvironmentType) (*ConfigFileInfo, error)

FindBestConfigFile 找到最合适的配置文件

func (*ConfigDiscovery) FindConfigFileByPattern added in v0.7.0

func (cd *ConfigDiscovery) FindConfigFileByPattern(searchPath, pattern string, env EnvironmentType) ([]*ConfigFileInfo, error)

FindConfigFileByPattern 根据模式查找配置文件

func (*ConfigDiscovery) ScanDirectory added in v0.7.0

func (cd *ConfigDiscovery) ScanDirectory(searchPath string) ([]*ConfigFileInfo, error)

ScanDirectory 扫描目录中的所有配置文件

type ConfigError added in v0.10.0

type ConfigError struct {
	Type       ErrorType              `json:"type"`        // 错误类型
	Severity   ErrorSeverity          `json:"severity"`    // 严重程度
	Message    string                 `json:"message"`     // 错误消息
	Source     string                 `json:"source"`      // 错误来源
	Timestamp  time.Time              `json:"timestamp"`   // 错误时间
	StackTrace string                 `json:"stack_trace"` // 堆栈跟踪
	Context    map[string]interface{} `json:"context"`     // 错误上下文
	Cause      error                  `json:"cause"`       // 原始错误
	Retryable  bool                   `json:"retryable"`   // 是否可重试
	Code       string                 `json:"code"`        // 错误代码
}

ConfigError 配置错误结构

func HandleError added in v0.10.0

func HandleError(ctx context.Context, err error) *ConfigError

HandleError 全局错误处理函数

func NewConfigError added in v0.10.0

func NewConfigError(errorType ErrorType, severity ErrorSeverity, message string) *ConfigError

NewConfigError 创建新的配置错误

func (*ConfigError) Error added in v0.10.0

func (e *ConfigError) Error() string

Error 实现 error 接口

func (*ConfigError) Is added in v0.10.0

func (e *ConfigError) Is(target error) bool

Is 实现 errors.Is 接口

func (*ConfigError) Unwrap added in v0.10.0

func (e *ConfigError) Unwrap() error

Unwrap 实现 errors.Unwrap 接口

func (*ConfigError) WithContext added in v0.10.0

func (e *ConfigError) WithContext(key string, value interface{}) *ConfigError

WithContext 添加上下文信息

type ConfigErrorHandler added in v0.10.0

type ConfigErrorHandler struct {
	// contains filtered or unexported fields
}

ConfigErrorHandler 配置错误处理器实现

func (*ConfigErrorHandler) ClassifyError added in v0.10.0

func (h *ConfigErrorHandler) ClassifyError(err error) (*ConfigError, ErrorType, ErrorSeverity)

ClassifyError 分类错误

func (*ConfigErrorHandler) ClearErrorStats added in v0.10.0

func (h *ConfigErrorHandler) ClearErrorStats()

ClearErrorStats 清除错误统计

func (*ConfigErrorHandler) GetErrorStats added in v0.10.0

func (h *ConfigErrorHandler) GetErrorStats() *ErrorStats

GetErrorStats 获取错误统计

func (*ConfigErrorHandler) HandleError added in v0.10.0

func (h *ConfigErrorHandler) HandleError(ctx context.Context, err error) *ConfigError

HandleError 处理错误

func (*ConfigErrorHandler) RegisterErrorCallback added in v0.10.0

func (h *ConfigErrorHandler) RegisterErrorCallback(callback ErrorCallback, filter ErrorFilter) error

RegisterErrorCallback 注册错误回调

func (*ConfigErrorHandler) UnregisterErrorCallback added in v0.10.0

func (h *ConfigErrorHandler) UnregisterErrorCallback(id string) error

UnregisterErrorCallback 注销错误回调

type ConfigFileInfo added in v0.7.0

type ConfigFileInfo struct {
	Path        string          `json:"path"`        // 文件完整路径
	Name        string          `json:"name"`        // 文件名(含扩展名)
	BaseName    string          `json:"base_name"`   // 文件名(不含扩展名)
	Extension   string          `json:"extension"`   // 文件扩展名
	Environment EnvironmentType `json:"environment"` // 环境类型
	Priority    int             `json:"priority"`    // 优先级(数字越小优先级越高)
	Exists      bool            `json:"exists"`      // 文件是否存在
}

ConfigFileInfo 配置文件信息

func AutoCreateConfig added in v0.7.0

func AutoCreateConfig(searchPath string, env EnvironmentType, configType string) (*ConfigFileInfo, error)

AutoCreateConfig 自动创建配置文件(便利函数)

func DiscoverConfig added in v0.7.0

func DiscoverConfig(searchPath string, env EnvironmentType) ([]*ConfigFileInfo, error)

DiscoverConfig 发现配置文件(便利函数)

func FindBestConfig added in v0.7.0

func FindBestConfig(searchPath string, env EnvironmentType) (*ConfigFileInfo, error)

FindBestConfig 找到最佳配置文件(便利函数)

func ScanAndDisplayConfigs added in v0.7.0

func ScanAndDisplayConfigs(searchPath string, env EnvironmentType) ([]*ConfigFileInfo, error)

ScanAndDisplayConfigs 扫描并显示可用的配置文件

type ConfigFormatter added in v0.7.0

type ConfigFormatter struct {
	// contains filtered or unexported fields
}

ConfigFormatter 配置格式化器

func GetGlobalConfigFormatter added in v0.7.0

func GetGlobalConfigFormatter() *ConfigFormatter

GetGlobalConfigFormatter 获取全局配置格式化器

func NewConfigFormatter added in v0.7.0

func NewConfigFormatter(lg ...*logger.Logger) *ConfigFormatter

NewConfigFormatter 创建配置格式化器

func (*ConfigFormatter) LogCache added in v0.7.0

func (cf *ConfigFormatter) LogCache(cacheConfig *cache.Cache)

LogCache 记录缓存配置

func (*ConfigFormatter) LogConfigChanged added in v0.7.0

func (cf *ConfigFormatter) LogConfigChanged(event CallbackEvent, newConfig interface{})

LogConfigChanged 记录配置变更 - 主要入口函数

func (*ConfigFormatter) LogDatabase added in v0.7.0

func (cf *ConfigFormatter) LogDatabase(dbConfig *database.Database)

LogDatabase 记录数据库配置

func (*ConfigFormatter) LogEnvironmentChanged added in v0.7.0

func (cf *ConfigFormatter) LogEnvironmentChanged(oldEnv, newEnv EnvironmentType)

LogEnvironmentChanged 记录环境变更

func (*ConfigFormatter) LogError added in v0.7.0

func (cf *ConfigFormatter) LogError(event CallbackEvent)

LogError 记录错误信息

func (*ConfigFormatter) LogGatewayDetails added in v0.7.0

func (cf *ConfigFormatter) LogGatewayDetails(config *gateway.Gateway)

LogGatewayDetails 记录Gateway详细配置信息

func (*ConfigFormatter) LogHTTPServer added in v0.7.0

func (cf *ConfigFormatter) LogHTTPServer(httpConfig *gateway.HTTPServer)

LogHTTPServer 记录HTTP服务器配置 - 您关注的重点

func (*ConfigFormatter) LogServiceStartup added in v0.7.0

func (cf *ConfigFormatter) LogServiceStartup(serviceName, endpoint, environment, version string)

LogServiceStartup 记录服务启动信息

func (*ConfigFormatter) LogValidation added in v0.7.0

func (cf *ConfigFormatter) LogValidation(isValid bool, err error, duration time.Duration)

LogValidation 记录配置验证结果

type ConfigLogger added in v0.7.0

type ConfigLogger struct {
	// contains filtered or unexported fields
}

ConfigLogger 配置日志输出器

func GetGlobalConfigLogger added in v0.7.0

func GetGlobalConfigLogger() *ConfigLogger

GetGlobalConfigLogger 获取全局配置日志器

func NewConfigLogger added in v0.7.0

func NewConfigLogger(loggerInstance ...*logger.Logger) *ConfigLogger

NewConfigLogger 创建新的配置日志输出器

func (*ConfigLogger) GetLogger added in v0.7.0

func (cl *ConfigLogger) GetLogger() *logger.Logger

GetLogger 获取日志器实例

func (*ConfigLogger) LogAPIEndpoints added in v0.7.0

func (cl *ConfigLogger) LogAPIEndpoints(endpoints map[string]string)

LogAPIEndpoints 记录API端点信息

func (*ConfigLogger) LogCacheConfig added in v0.7.0

func (cl *ConfigLogger) LogCacheConfig(cacheConfig *cache.Cache)

LogCacheConfig 记录缓存配置

func (*ConfigLogger) LogCallbackRegistration added in v0.7.0

func (cl *ConfigLogger) LogCallbackRegistration(callbackID string, callbackType []CallbackType, priority int)

LogCallbackRegistration 记录回调注册信息

func (*ConfigLogger) LogConfigChangeEvent added in v0.7.0

func (cl *ConfigLogger) LogConfigChangeEvent(event CallbackEvent, newConfig interface{})

LogConfigChangeEvent 记录配置变更事件

func (*ConfigLogger) LogConfigValidation added in v0.7.0

func (cl *ConfigLogger) LogConfigValidation(isValid bool, err error, duration time.Duration)

LogConfigValidation 记录配置验证结果

func (*ConfigLogger) LogDatabaseConfig added in v0.7.0

func (cl *ConfigLogger) LogDatabaseConfig(dbConfig *database.Database)

LogDatabaseConfig 记录数据库配置

func (*ConfigLogger) LogEnvironmentChangeEvent added in v0.7.0

func (cl *ConfigLogger) LogEnvironmentChangeEvent(oldEnv, newEnv EnvironmentType)

LogEnvironmentChangeEvent 记录环境变更事件

func (*ConfigLogger) LogErrorEvent added in v0.7.0

func (cl *ConfigLogger) LogErrorEvent(event CallbackEvent)

LogErrorEvent 记录错误事件

func (*ConfigLogger) LogGRPCConfig added in v0.7.0

func (cl *ConfigLogger) LogGRPCConfig(grpcConfig *gateway.GRPC)

LogGRPCConfig 记录GRPC配置

func (*ConfigLogger) LogGatewayConfig added in v0.7.0

func (cl *ConfigLogger) LogGatewayConfig(config *gateway.Gateway)

LogGatewayConfig 记录Gateway配置详情

func (*ConfigLogger) LogGenericConfig added in v0.7.0

func (cl *ConfigLogger) LogGenericConfig(config interface{})

LogGenericConfig 记录通用配置

func (*ConfigLogger) LogHTTPServerConfig added in v0.7.0

func (cl *ConfigLogger) LogHTTPServerConfig(httpConfig *gateway.HTTPServer)

LogHTTPServerConfig 记录HTTP服务器配置

func (*ConfigLogger) LogServiceShutdown added in v0.7.0

func (cl *ConfigLogger) LogServiceShutdown(serviceName string, duration time.Duration)

LogServiceShutdown 记录服务关闭信息

func (*ConfigLogger) LogServiceStartup added in v0.7.0

func (cl *ConfigLogger) LogServiceStartup(serviceName, endpoint, environment, version string)

LogServiceStartup 记录服务启动信息

func (*ConfigLogger) SetLogger added in v0.7.0

func (cl *ConfigLogger) SetLogger(logger *logger.Logger)

SetLogger 设置自定义日志器

type ContextKey added in v0.7.0

type ContextKey string

定义上下文键类型

const (
	ContextKeyEnvironment ContextKey = "go_config_environment"
	ContextKeyConfig      ContextKey = "go_config_configuration"
	ContextKeyHotReloader ContextKey = "go_config_hot_reloader"
	ContextKeyMetadata    ContextKey = "go_config_metadata"
)

上下文键定义

func GetContextKey added in v0.7.0

func GetContextKey() ContextKey

GetContextKey 获取当前的上下文键

func (ContextKey) String added in v0.7.0

func (c ContextKey) String() string

String 返回上下文键的字符串表示

type ContextKeyHelper added in v0.7.0

type ContextKeyHelper struct{}

ContextKeyHelper 上下文键辅助工具

func (ContextKeyHelper) IsEnvironment added in v0.7.0

func (ContextKeyHelper) IsEnvironment(ctx context.Context, env EnvironmentType) bool

IsEnvironment 检查上下文中的环境是否匹配

func (ContextKeyHelper) MustGetConfig added in v0.7.0

func (ContextKeyHelper) MustGetConfig(ctx context.Context) interface{}

MustGetConfig 从上下文中获取配置,如果不存在则panic

func (ContextKeyHelper) MustGetEnvironment added in v0.7.0

func (ContextKeyHelper) MustGetEnvironment(ctx context.Context) EnvironmentType

MustGetEnvironment 从上下文中获取环境,如果不存在则panic

func (ContextKeyHelper) NewConfigContext added in v0.7.0

func (ContextKeyHelper) NewConfigContext() context.Context

NewConfigContext 创建新的配置上下文

func (ContextKeyHelper) NewContextWithDeadline added in v0.7.0

func (ContextKeyHelper) NewContextWithDeadline(deadline time.Time) (context.Context, context.CancelFunc)

NewContextWithDeadline 创建带截止时间的配置上下文

func (ContextKeyHelper) NewContextWithTimeout added in v0.7.0

func (ContextKeyHelper) NewContextWithTimeout(timeout time.Duration) (context.Context, context.CancelFunc)

NewContextWithTimeout 创建带超时的配置上下文

type ContextKeyOptions added in v0.7.0

type ContextKeyOptions struct {
	Key   ContextKey
	Value EnvironmentType
}

ContextKeyOptions 定义上下文键的选项

type ContextManager added in v0.7.0

type ContextManager struct {
	// contains filtered or unexported fields
}

ContextManager 上下文管理器

func GetGlobalContextManager added in v0.7.0

func GetGlobalContextManager() *ContextManager

GetGlobalContextManager 获取全局上下文管理器

func InitializeContextManager added in v0.7.0

func InitializeContextManager(env *Environment, reloader HotReloader) *ContextManager

InitializeContextManager 初始化全局上下文管理器

func NewContextManager added in v0.7.0

func NewContextManager(env *Environment, reloader HotReloader) *ContextManager

NewContextManager 创建新的上下文管理器

func (*ContextManager) GetConfigContext added in v0.7.0

func (cm *ContextManager) GetConfigContext() *ConfigContext

GetConfigContext 获取完整的配置上下文

func (*ContextManager) GetCurrentConfig added in v0.7.0

func (cm *ContextManager) GetCurrentConfig() interface{}

GetCurrentConfig 获取当前配置

func (*ContextManager) GetCurrentEnvironment added in v0.7.0

func (cm *ContextManager) GetCurrentEnvironment() EnvironmentType

GetCurrentEnvironment 获取当前环境

func (*ContextManager) GetMetadata added in v0.7.0

func (cm *ContextManager) GetMetadata(key string) (interface{}, bool)

GetMetadata 获取元数据

func (*ContextManager) SetMetadata added in v0.7.0

func (cm *ContextManager) SetMetadata(key string, value interface{})

SetMetadata 设置元数据

func (*ContextManager) UpdateConfig added in v0.7.0

func (cm *ContextManager) UpdateConfig(config interface{})

UpdateConfig 更新配置

func (*ContextManager) WithConfig added in v0.7.0

func (cm *ContextManager) WithConfig(ctx context.Context) context.Context

WithConfig 将配置信息添加到上下文中

type Environment added in v0.7.0

type Environment struct {
	CheckFrequency time.Duration // 检查频率

	Value EnvironmentType // 当前环境值
	// contains filtered or unexported fields
}

环境配置

func Default added in v0.7.0

func Default() *Environment

Default 返回默认的 Environment 指针,支持链式调用

func DefaultEnvironment added in v0.7.0

func DefaultEnvironment() Environment

DefaultEnvironment 返回默认的 Environment 值

func GetGlobalEnvironment added in v0.12.4

func GetGlobalEnvironment() *Environment

GetGlobalEnvironment 获取全局环境实例,如果未初始化则自动初始化

func NewEnvironment added in v0.7.0

func NewEnvironment() *Environment

NewEnvironment 创建一个新的 Environment 实例,并将环境变量写入上下文

func (*Environment) CheckAndUpdateEnv added in v0.7.0

func (e *Environment) CheckAndUpdateEnv()

CheckAndUpdateEnv 检查并更新环境变量

func (*Environment) ClearCallbacks added in v0.7.0

func (e *Environment) ClearCallbacks()

ClearCallbacks 清除所有环境变更回调

func (*Environment) ClearEnv added in v0.7.0

func (e *Environment) ClearEnv()

ClearEnv 清除环境变量并等待锁

func (*Environment) ListCallbacks added in v0.7.0

func (e *Environment) ListCallbacks() []string

ListCallbacks 列出所有环境变更回调

func (*Environment) RegisterCallback added in v0.7.0

func (e *Environment) RegisterCallback(id string, callback EnvironmentCallback, priority int, async bool) error

RegisterCallback 注册环境变更回调

func (*Environment) RegisterEnvironment added in v0.7.0

func (e *Environment) RegisterEnvironment(env EnvironmentType) error

RegisterEnvironment 注册新的环境类型

func (*Environment) SetCheckFrequency added in v0.7.0

func (e *Environment) SetCheckFrequency(frequency time.Duration) *Environment

SetCheckFrequency 设置检查频率并支持链式调用

func (*Environment) SetEnvironment added in v0.7.0

func (e *Environment) SetEnvironment(value EnvironmentType) *Environment

SetEnvironment 设置环境变量

func (*Environment) StopWatch added in v0.7.0

func (e *Environment) StopWatch()

StopWatch 停止监控环境变量

func (*Environment) UnregisterCallback added in v0.7.0

func (e *Environment) UnregisterCallback(id string) error

UnregisterCallback 注销环境变更回调

type EnvironmentCallback added in v0.7.0

type EnvironmentCallback func(oldEnv, newEnv EnvironmentType) error

EnvironmentCallback 环境变更回调函数类型

type EnvironmentCallbackInfo added in v0.7.0

type EnvironmentCallbackInfo struct {
	ID       string              // 回调唯一标识
	Callback EnvironmentCallback // 回调函数
	Priority int                 // 优先级(数字越小优先级越高)
	Async    bool                // 是否异步执行
}

EnvironmentCallbackInfo 环境回调信息

type EnvironmentInterface added in v0.7.0

type EnvironmentInterface interface {
	SetEnvironment(value EnvironmentType) *Environment
	CheckAndUpdateEnv()
	SetCheckFrequency(frequency time.Duration) *Environment
	StopWatch()
	ClearEnv()
	RegisterCallback(id string, callback EnvironmentCallback, priority int, async bool) error
	UnregisterCallback(id string) error
	ListCallbacks() []string
	ClearCallbacks()
}

定义一个内部接口,隐藏实现细节

type EnvironmentManager added in v0.7.0

type EnvironmentManager struct {
	// contains filtered or unexported fields
}

EnvironmentManager 环境管理器

func GetGlobalEnvManager added in v0.12.4

func GetGlobalEnvManager() *EnvironmentManager

GetGlobalEnvManager 获取全局环境管理器 可用于注册自定义环境类型及其别名

func NewEnvironmentManager added in v0.7.0

func NewEnvironmentManager() *EnvironmentManager

NewEnvironmentManager 创建新的环境管理器

func (*EnvironmentManager) DetectEnvironmentType added in v0.7.0

func (em *EnvironmentManager) DetectEnvironmentType(envString string) (EnvironmentType, bool)

DetectEnvironmentType 检测环境字符串对应的环境类型

func (*EnvironmentManager) IsEnvironment added in v0.7.0

func (em *EnvironmentManager) IsEnvironment(envString string, envType EnvironmentType) bool

IsEnvironment 检查给定的环境字符串是否属于指定的环境类型

func (*EnvironmentManager) IsRegistered added in v0.7.0

func (em *EnvironmentManager) IsRegistered(envType EnvironmentType) bool

IsRegistered 检查环境类型是否已注册

func (*EnvironmentManager) RegisterEnvironment added in v0.7.0

func (em *EnvironmentManager) RegisterEnvironment(envType EnvironmentType, aliases ...string)

RegisterEnvironment 注册环境类型及其别名 同时会更新 DefaultEnvPrefixes,保持环境别名和配置文件前缀的一致性

type EnvironmentType added in v0.7.0

type EnvironmentType string

EnvironmentType 定义环境类型

func GetCurrentEnvironment added in v0.12.4

func GetCurrentEnvironment() EnvironmentType

GetCurrentEnvironment 获取当前环境类型(便捷函数)

func GetEnvironment added in v0.7.0

func GetEnvironment() EnvironmentType

GetEnvironment 从上下文中获取环境变量并解析为正确的环境类型

func GetEnvironmentFromContext added in v0.7.0

func GetEnvironmentFromContext(ctx context.Context) (EnvironmentType, bool)

GetEnvironmentFromContext 从上下文中获取环境信息

func (EnvironmentType) IsValid added in v0.7.0

func (e EnvironmentType) IsValid() bool

IsValid 检查环境类型是否有效

func (EnvironmentType) String added in v0.7.0

func (e EnvironmentType) String() string

String 返回环境类型的字符串表示

type ErrorCallback added in v0.10.0

type ErrorCallback func(ctx context.Context, configErr *ConfigError) error

ErrorCallback 错误回调函数类型

type ErrorFilter added in v0.10.0

type ErrorFilter struct {
	ID         string          `json:"id"`         // 回调ID
	Types      []ErrorType     `json:"types"`      // 监听的错误类型
	Severities []ErrorSeverity `json:"severities"` // 监听的严重程度
	Sources    []string        `json:"sources"`    // 监听的错误来源
}

ErrorFilter 错误过滤器

type ErrorHandler added in v0.10.0

type ErrorHandler interface {
	// HandleError 处理错误
	HandleError(ctx context.Context, err error) *ConfigError

	// ClassifyError 分类错误
	ClassifyError(err error) (*ConfigError, ErrorType, ErrorSeverity)

	// RegisterErrorCallback 注册错误回调
	RegisterErrorCallback(callback ErrorCallback, filter ErrorFilter) error

	// UnregisterErrorCallback 注销错误回调
	UnregisterErrorCallback(id string) error

	// GetErrorStats 获取错误统计
	GetErrorStats() *ErrorStats

	// ClearErrorStats 清除错误统计
	ClearErrorStats()
}

ErrorHandler 错误处理器接口

func GetGlobalErrorHandler added in v0.10.0

func GetGlobalErrorHandler() ErrorHandler

GetGlobalErrorHandler 获取全局错误处理器

func NewErrorHandler added in v0.10.0

func NewErrorHandler() ErrorHandler

NewErrorHandler 创建新的错误处理器

type ErrorSeverity added in v0.10.0

type ErrorSeverity int

ErrorSeverity 错误严重程度

const (
	SeverityDebug    ErrorSeverity = iota // 调试信息
	SeverityInfo                          // 信息
	SeverityWarn                          // 警告
	SeverityError                         // 错误
	SeverityCritical                      // 严重错误
	SeverityFatal                         // 致命错误
)

func (ErrorSeverity) String added in v0.10.0

func (s ErrorSeverity) String() string

String 实现 Stringer 接口

type ErrorStats added in v0.10.0

type ErrorStats struct {
	TotalErrors      int                   `json:"total_errors"`       // 总错误数
	ErrorsByType     map[ErrorType]int     `json:"errors_by_type"`     // 按类型分类
	ErrorsBySeverity map[ErrorSeverity]int `json:"errors_by_severity"` // 按严重程度分类
	ErrorsBySource   map[string]int        `json:"errors_by_source"`   // 按来源分类
	LastError        *ConfigError          `json:"last_error"`         // 最后一个错误
	FirstSeen        time.Time             `json:"first_seen"`         // 第一次看到错误的时间
	LastSeen         time.Time             `json:"last_seen"`          // 最后一次看到错误的时间
	RecentErrors     []*ConfigError        `json:"recent_errors"`      // 最近的错误(最多保留100个)
}

ErrorStats 错误统计

type ErrorType added in v0.10.0

type ErrorType string

ErrorType 错误类型枚举

const (
	ErrorTypeConfig        ErrorType = "config"        // 配置相关错误
	ErrorTypeFileSystem    ErrorType = "filesystem"    // 文件系统错误
	ErrorTypeNetwork       ErrorType = "network"       // 网络错误
	ErrorTypeValidation    ErrorType = "validation"    // 验证错误
	ErrorTypeSerialization ErrorType = "serialization" // 序列化错误
	ErrorTypeCallback      ErrorType = "callback"      // 回调执行错误
	ErrorTypePermission    ErrorType = "permission"    // 权限错误
	ErrorTypeTimeout       ErrorType = "timeout"       // 超时错误
	ErrorTypeInternal      ErrorType = "internal"      // 内部错误
	ErrorTypeExternal      ErrorType = "external"      // 外部错误
)

type HotReloadConfig added in v0.7.0

type HotReloadConfig struct {
	Enabled         bool          `yaml:"enabled" json:"enabled"`                   // 是否启用热更新
	WatchInterval   time.Duration `yaml:"watch_interval" json:"watch_interval"`     // 监控间隔
	DebounceDelay   time.Duration `yaml:"debounce_delay" json:"debounce_delay"`     // 防抖延迟
	MaxRetries      int           `yaml:"max_retries" json:"max_retries"`           // 最大重试次数
	CallbackTimeout time.Duration `yaml:"callback_timeout" json:"callback_timeout"` // 回调超时
	EnableEnvWatch  bool          `yaml:"enable_env_watch" json:"enable_env_watch"` // 是否监控环境变量
}

HotReloadConfig 热更新配置

func DefaultHotReloadConfig added in v0.7.0

func DefaultHotReloadConfig() *HotReloadConfig

DefaultHotReloadConfig 默认热更新配置

type HotReloader added in v0.7.0

type HotReloader interface {
	CallbackManager
	// Start 启动热更新监控
	Start(ctx context.Context) error
	// Stop 停止热更新监控
	Stop() error
	// Reload 手动重新加载配置
	Reload(ctx context.Context) error
	// IsRunning 检查是否正在运行
	IsRunning() bool
	// GetConfig 获取当前配置
	GetConfig() interface{}
	// SetConfig 设置配置
	SetConfig(config interface{}) error
}

HotReloader 热更新器接口

func GetHotReloaderFromContext added in v0.7.0

func GetHotReloaderFromContext(ctx context.Context) (HotReloader, bool)

GetHotReloaderFromContext 从上下文中获取热更新器

func NewHotReloader added in v0.7.0

func NewHotReloader(config interface{}, viper *viper.Viper, configPath string, options *HotReloadConfig) (HotReloader, error)

NewHotReloader 创建新的热更新器

type IntegratedConfigManager added in v0.7.0

type IntegratedConfigManager struct {
	// contains filtered or unexported fields
}

IntegratedConfigManager 集成配置管理器 统一管理配置文件、环境变量、热重载和上下文的核心组件

func CreateIntegratedManager added in v0.7.0

func CreateIntegratedManager(config interface{}, configPath string, env EnvironmentType) (*IntegratedConfigManager, error)

CreateIntegratedManager 创建集成配置管理器的便捷函数

func NewIntegratedConfigManager added in v0.7.0

func NewIntegratedConfigManager(config interface{}, options *IntegratedConfigOptions) (*IntegratedConfigManager, error)

NewIntegratedConfigManager 创建集成配置管理器

func QuickBuild added in v0.10.0

func QuickBuild[T any](config *T, configPath string, env EnvironmentType) (*IntegratedConfigManager, error)

QuickBuild 快速构建配置管理器的便捷函数

func QuickStart added in v0.10.0

func QuickStart[T any](config *T, configPath string, env EnvironmentType) (*IntegratedConfigManager, error)

QuickStart 快速启动配置管理器的便捷函数

func (*IntegratedConfigManager) ClearErrorStats added in v0.10.0

func (icm *IntegratedConfigManager) ClearErrorStats()

ClearErrorStats 清除错误统计信息

func (*IntegratedConfigManager) GetConfig added in v0.7.0

func (icm *IntegratedConfigManager) GetConfig() interface{}

GetConfig 获取当前配置

func (*IntegratedConfigManager) GetConfigMetadata added in v0.7.0

func (icm *IntegratedConfigManager) GetConfigMetadata() map[string]interface{}

GetConfigMetadata 获取配置元数据

func (*IntegratedConfigManager) GetContextManager added in v0.7.0

func (icm *IntegratedConfigManager) GetContextManager() *ContextManager

GetContextManager 获取上下文管理器

func (*IntegratedConfigManager) GetEnvironment added in v0.7.0

func (icm *IntegratedConfigManager) GetEnvironment() EnvironmentType

GetEnvironment 获取当前环境

func (*IntegratedConfigManager) GetEnvironmentManager added in v0.7.0

func (icm *IntegratedConfigManager) GetEnvironmentManager() *Environment

GetEnvironmentManager 获取环境管理器

func (*IntegratedConfigManager) GetErrorHandler added in v0.10.0

func (icm *IntegratedConfigManager) GetErrorHandler() ErrorHandler

GetErrorHandler 获取错误处理器

func (*IntegratedConfigManager) GetErrorStats added in v0.10.0

func (icm *IntegratedConfigManager) GetErrorStats() *ErrorStats

GetErrorStats 获取错误统计信息

func (*IntegratedConfigManager) GetHotReloader added in v0.7.0

func (icm *IntegratedConfigManager) GetHotReloader() HotReloader

GetHotReloader 获取热重载器

func (*IntegratedConfigManager) GetViper added in v0.7.0

func (icm *IntegratedConfigManager) GetViper() *viper.Viper

GetViper 获取Viper实例

func (*IntegratedConfigManager) IsRunning added in v0.7.0

func (icm *IntegratedConfigManager) IsRunning() bool

IsRunning 检查管理器是否正在运行

func (*IntegratedConfigManager) MustStart added in v0.7.0

func (icm *IntegratedConfigManager) MustStart(ctx context.Context)

MustStart 必须成功启动配置管理器

func (*IntegratedConfigManager) RegisterConfigCallback added in v0.7.0

func (icm *IntegratedConfigManager) RegisterConfigCallback(callback CallbackFunc, options CallbackOptions) error

RegisterConfigCallback 注册配置变更回调

func (*IntegratedConfigManager) RegisterEnvironmentCallback added in v0.7.0

func (icm *IntegratedConfigManager) RegisterEnvironmentCallback(id string, callback EnvironmentCallback, priority int, async bool) error

RegisterEnvironmentCallback 注册环境变更回调

func (*IntegratedConfigManager) RegisterErrorCallback added in v0.10.0

func (icm *IntegratedConfigManager) RegisterErrorCallback(callback ErrorCallback, filter ErrorFilter) error

RegisterErrorCallback 注册错误回调

func (*IntegratedConfigManager) SetEnvironment added in v0.7.0

func (icm *IntegratedConfigManager) SetEnvironment(env EnvironmentType) error

SetEnvironment 设置应用环境

func (*IntegratedConfigManager) Start added in v0.7.0

func (icm *IntegratedConfigManager) Start(ctx context.Context) error

Start 启动配置管理器

func (*IntegratedConfigManager) Stop added in v0.7.0

func (icm *IntegratedConfigManager) Stop() error

Stop 停止配置管理器

func (*IntegratedConfigManager) UnregisterConfigCallback added in v0.7.0

func (icm *IntegratedConfigManager) UnregisterConfigCallback(id string) error

UnregisterConfigCallback 取消配置变更回调

func (*IntegratedConfigManager) UnregisterEnvironmentCallback added in v0.7.0

func (icm *IntegratedConfigManager) UnregisterEnvironmentCallback(id string) error

UnregisterEnvironmentCallback 取消环境变更回调

func (*IntegratedConfigManager) UnregisterErrorCallback added in v0.10.0

func (icm *IntegratedConfigManager) UnregisterErrorCallback(id string) error

UnregisterErrorCallback 取消错误回调

func (*IntegratedConfigManager) ValidateConfig added in v0.7.0

func (icm *IntegratedConfigManager) ValidateConfig() error

ValidateConfig 验证配置有效性

func (*IntegratedConfigManager) WithContext added in v0.7.0

func (icm *IntegratedConfigManager) WithContext(ctx context.Context) context.Context

WithContext 将配置信息注入到上下文中

type IntegratedConfigOptions added in v0.7.0

type IntegratedConfigOptions struct {
	ConfigPath      string             // 配置文件路径
	Environment     EnvironmentType    // 初始环境
	HotReloadConfig *HotReloadConfig   // 热更新配置
	ContextOptions  *ContextKeyOptions // 上下文选项
	ErrorHandler    ErrorHandler       // 错误处理器
}

IntegratedConfigOptions 集成配置管理器选项

func DefaultIntegratedConfigOptions added in v0.7.0

func DefaultIntegratedConfigOptions() *IntegratedConfigOptions

DefaultIntegratedConfigOptions 默认集成配置管理器选项

type ManagerBuilder added in v0.8.0

type ManagerBuilder[T any] struct {
	// contains filtered or unexported fields
}

ManagerBuilder 配置管理器构建器实现

func (*ManagerBuilder[T]) Build added in v0.8.0

func (b *ManagerBuilder[T]) Build() (*IntegratedConfigManager, error)

Build 构建配置管理器

func (*ManagerBuilder[T]) BuildAndStart added in v0.8.0

func (b *ManagerBuilder[T]) BuildAndStart(ctx ...context.Context) (*IntegratedConfigManager, error)

BuildAndStart 构建并启动配置管理器

func (*ManagerBuilder[T]) MustBuildAndStart added in v0.8.0

func (b *ManagerBuilder[T]) MustBuildAndStart(ctx ...context.Context) *IntegratedConfigManager

MustBuildAndStart 构建并启动配置管理器

func (*ManagerBuilder[T]) WithConfigPath added in v0.8.0

func (b *ManagerBuilder[T]) WithConfigPath(path string) ConfigBuilder[T]

WithConfigPath 设置配置文件路径

func (*ManagerBuilder[T]) WithContext added in v0.8.0

func (b *ManagerBuilder[T]) WithContext(options *ContextKeyOptions) ConfigBuilder[T]

WithContext 设置上下文配置选项

func (*ManagerBuilder[T]) WithEnvironment added in v0.8.0

func (b *ManagerBuilder[T]) WithEnvironment(env EnvironmentType) ConfigBuilder[T]

WithEnvironment 设置运行环境

func (*ManagerBuilder[T]) WithErrorHandler added in v0.10.0

func (b *ManagerBuilder[T]) WithErrorHandler(handler ErrorHandler) ConfigBuilder[T]

WithErrorHandler 设置错误处理器

func (*ManagerBuilder[T]) WithHotReload added in v0.8.0

func (b *ManagerBuilder[T]) WithHotReload(config *HotReloadConfig) ConfigBuilder[T]

WithHotReload 启用配置热重载功能

func (*ManagerBuilder[T]) WithPattern added in v0.8.0

func (b *ManagerBuilder[T]) WithPattern(pattern string) ConfigBuilder[T]

WithPattern 设置文件匹配模式

func (*ManagerBuilder[T]) WithPrefix added in v0.8.0

func (b *ManagerBuilder[T]) WithPrefix(prefix string) ConfigBuilder[T]

WithPrefix 设置配置文件名前缀

func (*ManagerBuilder[T]) WithSearchPath added in v0.8.0

func (b *ManagerBuilder[T]) WithSearchPath(path string) ConfigBuilder[T]

WithSearchPath 设置配置文件搜索路径

type ModuleConfig added in v0.10.0

type ModuleConfig struct {
	Name          string             // 模块名称
	PackageName   string             // 包名
	DefaultFunc   func() interface{} // 默认配置函数
	OutputSubDir  string             // 输出子目录
	SourceFile    string             // 源文件路径
	StructName    string             // 结构体名称
	Description   string             // 模块描述
	Enabled       bool               // 是否启用此模块生成
	LastGenerated time.Time          // 最后生成时间
}

ModuleConfig 模块配置信息

type SmartConfigGenerator added in v0.10.0

type SmartConfigGenerator struct {
	BaseOutputDir     string                  // 基础输出目录
	Logger            *gologger.Logger        // 日志记录器
	ModuleRegistry    map[string]ModuleConfig // 模块注册表
	ForceRegenerate   bool                    // 是否强制重新生成
	IncludeComments   bool                    // 是否包含注释
	GenerateJSON      bool                    // 是否生成JSON
	GenerateYAML      bool                    // 是否生成YAML
	BackupExisting    bool                    // 是否备份现有文件
	OverwriteExisting bool                    // 是否覆盖现有文件
	// contains filtered or unexported fields
}

SmartConfigGenerator 智能配置生成器

func NewSmartConfigGenerator added in v0.10.0

func NewSmartConfigGenerator(baseOutputDir string) *SmartConfigGenerator

NewSmartConfigGenerator 创建新的智能配置生成器

func (*SmartConfigGenerator) CleanupBackupFiles added in v0.10.0

func (sg *SmartConfigGenerator) CleanupBackupFiles(maxAge time.Duration) error

CleanupBackupFiles 清理备份文件

func (*SmartConfigGenerator) DisableModule added in v0.10.0

func (sg *SmartConfigGenerator) DisableModule(moduleName string) error

DisableModule 禁用指定模块

func (*SmartConfigGenerator) EnableModule added in v0.10.0

func (sg *SmartConfigGenerator) EnableModule(moduleName string) error

EnableModule 启用指定模块

func (*SmartConfigGenerator) EnableOnlyModules added in v0.10.0

func (sg *SmartConfigGenerator) EnableOnlyModules(moduleNames ...string) error

EnableOnlyModules 只启用指定的模块,其他模块全部禁用

func (*SmartConfigGenerator) GenerateAllConfigs added in v0.10.0

func (sg *SmartConfigGenerator) GenerateAllConfigs() error

GenerateAllConfigs 生成所有模块的配置文件

func (*SmartConfigGenerator) GenerateModuleConfig added in v0.10.0

func (sg *SmartConfigGenerator) GenerateModuleConfig(module ModuleConfig) error

GenerateModuleConfig 生成单个模块的配置文件

func (*SmartConfigGenerator) GenerateModulesByNames added in v0.10.0

func (sg *SmartConfigGenerator) GenerateModulesByNames(moduleNames ...string) error

GenerateModulesByNames 根据模块名称生成指定模块的配置文件

func (*SmartConfigGenerator) GetEnabledModules added in v0.10.0

func (sg *SmartConfigGenerator) GetEnabledModules() []string

GetEnabledModules 获取已启用的模块列表

func (*SmartConfigGenerator) GetModuleInfo added in v0.10.0

func (sg *SmartConfigGenerator) GetModuleInfo(moduleName string) (*ModuleConfig, error)

GetModuleInfo 获取模块详细信息

func (*SmartConfigGenerator) GetModuleList added in v0.10.0

func (sg *SmartConfigGenerator) GetModuleList() []string

GetModuleList 获取所有注册的模块列表

func (*SmartConfigGenerator) PrintModuleStatus added in v0.10.0

func (sg *SmartConfigGenerator) PrintModuleStatus()

PrintModuleStatus 打印模块状态

func (*SmartConfigGenerator) UpdateModuleConfig added in v0.10.0

func (sg *SmartConfigGenerator) UpdateModuleConfig(moduleName string, updates map[string]interface{}) error

UpdateModuleConfig 更新模块配置

func (*SmartConfigGenerator) ValidateAllModules added in v0.10.0

func (sg *SmartConfigGenerator) ValidateAllModules() error

ValidateAllModules 验证所有模块配置

func (*SmartConfigGenerator) ValidateModuleConfig added in v0.10.0

func (sg *SmartConfigGenerator) ValidateModuleConfig(moduleName string) error

ValidateModuleConfig 验证模块配置

func (*SmartConfigGenerator) WithBackupExisting added in v0.10.0

func (sg *SmartConfigGenerator) WithBackupExisting(backup bool) *SmartConfigGenerator

WithBackupExisting 设置是否备份现有文件

func (*SmartConfigGenerator) WithForceRegenerate added in v0.10.0

func (sg *SmartConfigGenerator) WithForceRegenerate(force bool) *SmartConfigGenerator

WithForceRegenerate 设置是否强制重新生成

func (*SmartConfigGenerator) WithIncludeComments added in v0.10.0

func (sg *SmartConfigGenerator) WithIncludeComments(include bool) *SmartConfigGenerator

WithIncludeComments 设置是否包含注释

func (*SmartConfigGenerator) WithLogger added in v0.10.0

func (sg *SmartConfigGenerator) WithLogger(logger *gologger.Logger) *SmartConfigGenerator

WithLogger 设置日志记录器

Directories

Path Synopsis
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2024-11-07 23:55:15 * @FilePath: \go-config\internal\common.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2024-11-07 23:55:15 * @FilePath: \go-config\internal\common.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
pkg
database
* @Author: kamalyes [email protected] * @Date: 2024-11-03 20:55:05 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-12 22:50:17 * @FilePath: \go-config\pkg\database\database.go * @Description: 数据库统一配置管理 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes [email protected] * @Date: 2024-11-03 20:55:05 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-12 22:50:17 * @FilePath: \go-config\pkg\database\database.go * @Description: 数据库统一配置管理 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
elasticsearch
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2024-11-07 23:59:11 * @FilePath: \go-config\pkg\elasticsearch\elasticsearch.go * @Description: * * Copyright (j) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2024-11-07 23:59:11 * @FilePath: \go-config\pkg\elasticsearch\elasticsearch.go * @Description: * * Copyright (j) 2024 by kamalyes, All Rights Reserved.
ftp
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-09 01:32:31 * @FilePath: \go-config\pkg\ftp\ftp.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-09 01:32:31 * @FilePath: \go-config\pkg\ftp\ftp.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
jwt
kafka
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-15 13:26:00 * @FilePath: \go-config\pkg\kafka\kafka.go * @Description: * * Copyright (j) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2025-11-15 13:26:00 * @FilePath: \go-config\pkg\kafka\kafka.go * @Description: * * Copyright (j) 2024 by kamalyes, All Rights Reserved.
oss
pay
sms
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2024-11-07 23:53:49 * @FilePath: \go-config\pkg\sms\aliyun.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes [email protected] * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes [email protected] * @LastEditTime: 2024-11-07 23:53:49 * @FilePath: \go-config\pkg\sms\aliyun.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
sts
wsc
zap

Jump to

Keyboard shortcuts

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