Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInitialized = errors.New("指针文件不存在,应用未初始化")

ErrNotInitialized 表示指针文件不存在,应用尚未完成首次初始化。没初始化弹出来初始化界面,如果初始化了但是还是出错就谈配置错误恢复

Functions

func DataDirPath

func DataDirPath() string

DataDirPath 返回数据根目录(绝对路径)。

func Decrypt added in v1.7.0

func Decrypt(data []byte) ([]byte, error)

func Encrypt added in v1.7.0

func Encrypt(plain []byte) ([]byte, error)

Encrypt 使用应用固定密钥,返回与既有 LLM 配置兼容的 nonce + 密文格式。

func GlobalDBPath

func GlobalDBPath() string

GlobalDBPath 返回全局数据库路径。

func LLMConfigPath

func LLMConfigPath() string

LLMConfigPath 返回 LLM 加密配置文件的固定路径 ~/.goink/llm_config.enc。

func MCPClientConfigPath added in v1.7.0

func MCPClientConfigPath() string

func MCPServerConfigPath added in v1.7.0

func MCPServerConfigPath() string

func ModelsDir

func ModelsDir() string

ModelsDir 返回 ONNX 模型目录路径。 优先查安装包自带的 runtime/models/,找不到再 fallback 到用户数据目录。

func NovelDirPath

func NovelDirPath(novelID int64) string

NovelDirPath 返回指定小说的 Git 仓库根目录。

func NovelSkillsDir

func NovelSkillsDir(novelID int64) string

NovelSkillsDir 返回指定小说的 skill 目录。

func Save

func Save(dataDir string) error

Save 将数据目录路径写入指针文件。自动展开 ~ 并转为绝对路径。 如果 ~/.goink/ 目录不存在则自动创建。

func SaveSettings

func SaveSettings(db *gorm.DB, s *AppSettings) error

SaveSettings 将配置写回全局库。

func Set

func Set(cfg *AppConfig)

Set 设置全局配置单例,InitWithConfig 成功后调用。

func StyleSamplesDir

func StyleSamplesDir() string

StyleSamplesDir 返回全局风格素材目录 ~/.goink/style_samples/。

func UserSkillsDir

func UserSkillsDir() string

UserSkillsDir 返回用户级 skill 目录 ~/.goink/skills/。

Types

type AppConfig

type AppConfig struct {
	DataDir string `json:"data_dir"` // 用户选择的数据根目录(保留字段)
}

AppConfig 是启动指针文件 ~/.goink/config.json 的内容。 DataDir 字段保留用于未来扩展,当前数据目录由 platform.DataDir() 确定。

func Get

func Get() *AppConfig

Get 返回全局配置单例,未初始化时返回 nil。

func Load

func Load() (*AppConfig, error)

Load 读取启动指针文件,返回 AppConfig。 文件不存在时返回错误,调用方应引导用户完成初始化。

type AppSettings

type AppSettings struct {
	ID                uint      `gorm:"column:id;primaryKey;default:1"`
	LastNovelID       int64     `gorm:"column:last_novel_id;default:0"       json:"last_novel_id"`
	SelectedModelKey  string    `gorm:"column:selected_model_key;default:''"  json:"selected_model_key"`
	ReasoningEffort   string    `gorm:"column:reasoning_effort;default:''"    json:"reasoning_effort"`
	ApprovalMode      string    `gorm:"column:approval_mode;default:manual"   json:"approval_mode"`
	LastSessionID     string    `gorm:"column:last_session_id;default:''"     json:"last_session_id"`
	UserName          string    `gorm:"column:user_name;default:''"            json:"user_name"`
	GitName           string    `gorm:"column:git_name;default:'Goink'"         json:"git_name"`
	GitEmail          string    `gorm:"column:git_email;default:'goink@local'"  json:"git_email"`
	DismissedVersion  string    `gorm:"column:dismissed_version;default:''"     json:"dismissed_version"`     // 用户已忽略的更新版本号
	LastUpdateCheckAt time.Time `gorm:"column:last_update_check_at"              json:"last_update_check_at"` // 上次自动更新检查时间,用于 12h 节流;零值表示从未检查

	TrackingStartedAt *time.Time `gorm:"column:tracking_started_at" json:"-"`
	TrackingStartDate string     `gorm:"column:tracking_start_date;not null;default:''" json:"-"`
}

AppSettings 是全局 app_config 表的单行配置。 适合存放更新频率低,重要的,其他可前端localstorage。 增删配置项直接在此 struct 加减字段即可,GORM 自动迁移。

func LoadSettings

func LoadSettings(db *gorm.DB) (*AppSettings, error)

LoadSettings 从全局库读取配置(单行)。首次使用时自动创建空行。

func (AppSettings) TableName

func (AppSettings) TableName() string

Jump to

Keyboard shortcuts

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