config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config 管理 seek 的命名配置档 (profiles)。

设计对照 ant 的 `profile` 命令: 配置存在 ~/.config/seek/config.json, 顶层 active_config 指向当前激活的 profile, profiles 里每个 key 是一个 profile。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir 返回配置目录, 遵循 XDG 约定, 默认 ~/.config/seek。

func Path

func Path() (string, error)

Path 返回配置文件完整路径。

func Save

func Save(c *Config) error

Save 把配置写回磁盘, 权限 0600 (含密钥)。

Types

type Config

type Config struct {
	ActiveConfig string             `json:"active_config"`
	Profiles     map[string]Profile `json:"profiles"`
}

Config 是整个配置文件的结构。

func Load

func Load() (*Config, error)

Load 读取配置文件; 文件不存在时返回一个空的默认配置。

func (*Config) Get

func (c *Config) Get(name string) Profile

Get 返回指定 profile (不存在则返回空 Profile)。

func (*Config) Names

func (c *Config) Names() []string

Names 返回所有 profile 名称, 已排序。

func (*Config) Resolve

func (c *Config) Resolve(name string) string

Resolve 选出生效的 profile 名称: 优先显式传入, 否则用 active_config。

type Profile

type Profile struct {
	APIKey  string `json:"api_key,omitempty"`
	BaseURL string `json:"base_url,omitempty"`
}

Profile 是单个配置档。DeepSeek 没有 OAuth, 因此凭据就是一个 API key。

Jump to

Keyboard shortcuts

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