cmd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cmd 提供了命令行参数解析和配置管理功能。 支持从命令行参数、环境变量和配置文件加载配置。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateConfig

func ValidateConfig(cfg *Config) error

ValidateConfig 验证配置的有效性

Types

type Config

type Config struct {
	Port             string // 16 bytes
	Redis            string // 16 bytes
	RedisPassword    string // 16 bytes
	RedisEnabled     bool   // 1 byte (padding to 8 bytes)
	RemoteConfig     string // 16 bytes
	RemoteKey        string // 16 bytes
	Mode             string // 16 bytes
	APIKey           string // 16 bytes
	TaskInterval     int    // 8 bytes
	HTTPTimeout      int    // 8 bytes
	HTTPMaxIdleConns int    // 8 bytes
	HTTPInsecureTLS  bool   // 1 byte (padding to 8 bytes)
}

Config 存储应用配置

func GetArgs

func GetArgs() *Config

GetArgs 解析命令行参数和环境变量,返回配置结构体 优先级:命令行参数 > 环境变量 > 配置文件 > 默认值 如果提供了 -config-file 参数,会尝试从配置文件加载

func LoadConfig

func LoadConfig(configFile string) (*Config, error)

LoadConfig 加载配置(新接口,支持配置文件) 优先级:命令行参数 > 环境变量 > 配置文件 > 默认值

Jump to

Keyboard shortcuts

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