Skip to content

⚙️ 配置

配置可通过环境变量配置文件命令行参数注入,优先级:参数 > 环境变量 > 文件。

配置文件

默认路径 ~/.config/go-icp/config.yaml,可用 --config 覆盖。

yaml
# 数据源
sources:
  zhudun:
    enabled: true
    credentials:
      - key: "${ZHUDUN_KEY_1}"
        quota_daily: 1000
  miit:
    enabled: true              # 补全路径

# 点选 OCR
ocr:
  endpoint: "${OCR_ENDPOINT}"
  token: "${OCR_TOKEN}"
  max_retry: 3

# 限速
rate_limit:
  zhudun: 5    # req/s
  miit: 1      # req/s

# 缓存
cache:
  backend: file
  dir: ~/.cache/go-icp
  ttl: 24h

# 输出
output:
  format: json
  pretty: true

# 日志
log:
  level: info
  format: json

环境变量

所有配置项均可映射为 GO_ICP_<SECTION>_<KEY>,例如:

配置项环境变量
sources.zhudun.credentials[0].keyZHUDUN_KEY_1
ocr.tokenOCR_TOKEN
cache.ttlGO_ICP_CACHE_TTL
log.levelGO_ICP_LOG_LEVEL

完整映射见 ⚙️ 配置项

校验

bash
go-icp doctor        # 检查配置与凭证可用性

详见 🩺 doctor

📚 延伸阅读

Released under the MIT License.