Documentation
¶
Overview ¶
Package paths resolves absolute, writable locations for the bot's runtime files. Two distinct trees are exposed:
- GetAssetsDir / Resolve: read-only assets (templates, strategies). In a packaged .app this is inside the bundle's Resources/ folder; in dev mode it's the in-tree assets/ dir.
- GetConfigDir / ResolveConfig: writable state (boot_profile, stats, attack_history, last_attack_report, attack_deploy_debug outputs, logs/). The default lives outside the project root on every platform so the wails dev filesystem watcher never sees state writes — wails dev treats any project-tree file change as a Go rebuild trigger and kills the active bot session to relaunch.
Resolution order for GetConfigDir:
- CLASHGO_CONFIG_DIR env var (tests, portable installs).
- macOS .app-style bundle → ~/Library/Application Support/ClashGO (covers both wails dev's build/bin/ClashGO.app and the production .app, since both ship Resources/assets — see isPackagedApp).
- non-mac dev → $XDG_CONFIG_HOME/ClashGO/dev on linux %APPDATA%/ClashGO/dev on windows (os.UserConfigDir() picks the right base)
- fallback → os.TempDir()/ClashGO/dev
Legacy compatibility: the first GetConfigDir() call runs a one-time migration that copies known state files from the project's cwd into the resolved directory. Copy-not-move — the legacy copy stays where it was so manual recovery is trivial and a failed migration cannot lose data. Re-runs are also harmless: sync.Once + os.OpenFile(O_EXCL) ensure destination files are never truncated or overwritten.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAssetsDir ¶
func GetAssetsDir() string
GetAssetsDir returns the absolute path to the assets directory, honoring CLASHGO_ASSETS_DIR at call time so tests and portable installs can override without rebuilding.
func GetConfigDir ¶
func GetConfigDir() string
GetConfigDir returns the absolute path to the dir used for writable config and per-run state files. Reads CLASHGO_CONFIG_DIR on every call (via resolveConfigDir) so tests using t.Setenv still redirect, and runs the legacy migration at most once per process via sync.Once.
func Resolve ¶
Resolve joins the assets dir with a subpath (e.g. Resolve("templates") → <assets>/templates). Read-only by intent; callers needing a writable location should use ResolveConfig.
func ResolveConfig ¶
ResolveConfig joins the config dir with a subpath (e.g. ResolveConfig("stats.json") → <configDir>/stats.json). All per-run state reads/writes should funnel through this so the wails dev watcher never sees them.
Types ¶
This section is empty.