Documentation
¶
Index ¶
- Constants
- func AtomicWriteFile(path string, data []byte, perm os.FileMode) error
- func ClearHistory() error
- func DefaultSnapshotDir() (string, error)
- func ExportSnapshot(snapshot Snapshot, filePath string) error
- func PresetsDir() (string, error)
- func SanitizeFilename(name string) string
- func SaveConfig(cfg Config) error
- func SaveHistory(history SessionHistory, maxEntries int) error
- func SortModeToString(mode SortMode) string
- func UniqueFilePath(dir, base, ext string) string
- type Config
- type EditRecord
- type Preset
- type SessionHistory
- type Snapshot
- type SnapshotDiff
- type SortMode
Constants ¶
const ConfigDirName = "goenv"
const ThemeDefault = "default"
ThemeDefault is the default theme name.
Variables ¶
This section is empty.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile writes data to a file atomically by writing to a temp file and renaming (atomic on POSIX).
func DefaultSnapshotDir ¶
DefaultSnapshotDir returns the default directory for snapshots.
func ExportSnapshot ¶
ExportSnapshot saves a snapshot to a JSON file.
func PresetsDir ¶
PresetsDir returns the directory for storing presets.
func SanitizeFilename ¶
SanitizeFilename removes or replaces invalid filename characters.
func SaveHistory ¶
func SaveHistory(history SessionHistory, maxEntries int) error
SaveHistory persists history to disk. maxEntries controls the maximum number of history records to keep. If maxEntries <= 0, the default of 50 is used.
func SortModeToString ¶
SortModeToString converts a SortMode to string.
func UniqueFilePath ¶
UniqueFilePath returns a file path that doesn't collide with existing files. If dir/base.ext exists, it tries dir/base_2.ext, dir/base_3.ext, etc.
Types ¶
type Config ¶
type Config struct {
SortMode string `json:"sortMode"`
Theme string `json:"theme,omitempty"`
Favorites []string `json:"favorites,omitzero"`
WatchInterval int `json:"watchInterval,omitempty"`
MaxHistory int `json:"maxHistory,omitempty"`
}
Config holds user preferences that persist across sessions.
func LoadConfig ¶
LoadConfig loads configuration from disk. Returns default config if file doesn't exist.
type EditRecord ¶
type EditRecord struct {
Key string `json:"key"`
OldValue string `json:"oldValue"`
NewValue string `json:"newValue"`
}
EditRecord stores a single edit operation for undo/redo functionality.
type Preset ¶
Preset represents a named environment configuration.
func BuiltinPresets ¶
func BuiltinPresets() []Preset
BuiltinPresets returns the set of built-in starter presets. These are shipped with goenv and cannot be deleted by the user.
func ListPresets ¶
ListPresets returns all saved presets. Also returns the count of files that could not be parsed.
type SessionHistory ¶
type SessionHistory struct {
Records []EditRecord `json:"records"`
CurrentIdx int `json:"currentIdx"`
}
SessionHistory stores edit history that persists across sessions.
func LoadHistory ¶
func LoadHistory() (SessionHistory, error)
LoadHistory loads history from disk. Returns empty history if file doesn't exist.
type Snapshot ¶
type Snapshot struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
CreatedAt time.Time `json:"createdAt"`
GoVersion string `json:"goVersion,omitempty"`
Variables map[string]string `json:"variables"`
}
Snapshot represents a saved state of Go environment variables.
func ImportSnapshot ¶
ImportSnapshot loads a snapshot from a JSON file.
func ListSnapshots ¶
ListSnapshots returns all snapshots in the default directory. Also returns the count of files that could not be parsed.
type SnapshotDiff ¶
type SnapshotDiff struct {
Added map[string]string // In snapshot but not current
Removed map[string]string // In current but not snapshot
Modified map[string]struct {
Current string
Snapshot string
}
Unchanged []string
}
SnapshotDiff represents the difference between current env and a snapshot.
func CompareWithSnapshot ¶
func CompareWithSnapshot(items []goenv.EnvVar, snapshot Snapshot) SnapshotDiff
CompareWithSnapshot compares current environment with a snapshot.
type SortMode ¶
type SortMode int
SortMode determines how environment variables are sorted in the list.
const ( SortAlpha SortMode = iota // Alphabetical by key SortModifiedFirst // Modified variables first, then alphabetical SortCategory // Grouped by category, then alphabetical )
Sort mode options.
func SortModeFromString ¶
SortModeFromString converts a string to SortMode.