config

package
v0.0.0-...-9d73d16 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalStore *lingstorage.Client

Functions

func Load

func Load() error

Load 读取环境(含可选 .env / .env.$MODE),填充 GlobalConfig。

Types

type Config

type Config struct {
	Server   ServerConfig     `mapstructure:"server"`
	Database DatabaseConfig   `mapstructure:"database"`
	Log      logger.LogConfig `mapstructure:"log"`
	Services ServicesConfig   `mapstructure:"services"`
}

Config 应用主配置(精简版:仅服务、数据库、日志与 LLM)。

var GlobalConfig *Config

GlobalConfig 进程级单例,在 Load 成功后可用。

func (*Config) LogMode

func (c *Config) LogMode() string

LogMode 将 Server.Mode 映射为 logger.Init 的 mode 参数。

func (*Config) Validate

func (c *Config) Validate() error

Validate 校验关键字段。

type DatabaseConfig

type DatabaseConfig struct {
	Driver string `env:"DB_DRIVER"`
	DSN    string `env:"DSN"`
}

DatabaseConfig 数据库连接。

type LLMConfig

type LLMConfig struct {
	Provider string `env:"LLM_PROVIDER"` // openai | ollama | lmstudio 等,走 OpenAI 兼容 Chat Completions
	APIKey   string `env:"LLM_API_KEY"`
	BaseURL  string `env:"LLM_BASE_URL"`
	Model    string `env:"LLM_MODEL"`
}

LLMConfig 大模型调用(供后续引擎使用)。

type ServerConfig

type ServerConfig struct {
	Name      string `env:"SERVER_NAME"`
	Addr      string `env:"ADDR"`
	Mode      string `env:"MODE"`
	APIPrefix string `env:"API_PREFIX"`
}

ServerConfig HTTP 服务相关。

type ServicesConfig

type ServicesConfig struct {
	LLM     LLMConfig     `mapstructure:"llm"`
	Storage StorageConfig `mapstructure:"storage"`
}

ServicesConfig 外部服务。

type StorageConfig

type StorageConfig struct {
	BaseURL   string `env:"LINGSTORAGE_BASE_URL"`
	APIKey    string `env:"LINGSTORAGE_API_KEY"`
	APISecret string `env:"LINGSTORAGE_API_SECRET"`
	Bucket    string `env:"LINGSTORAGE_BUCKET"`
}

StorageConfig storage configuration

Jump to

Keyboard shortcuts

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