Documentation
¶
Index ¶
- func Backup(filename string, isSystem bool) (int, error)
- func Export(filename string, envVars []EnvVar) error
- func GetSystem(key string) (string, error)
- func GetUser(key string) (string, error)
- func ParseEnvFile(content []byte, startWith string) ([]doraemon.Pair[string, string], error)
- func Restore(filename string, isSystem bool) (int, error)
- func Set(key, value string) error
- func SetPS(key, value string) error
- func SetSystem(key, value string) error
- func Unset(key string) error
- func UnsetSystem(key string) error
- type BackupData
- type EnvVar
- type ExportFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseEnvFile ¶
ParseEnvFile parses environment file content and returns key-value pairs. It supports optional prefix filtering with startWith parameter.
func SetPS ¶
SetPS sets a user environment variable using PowerShell. This method handles keys and values containing '&' correctly.
func SetSystem ¶
SetSystem sets a system environment variable using setx /m command. Requires administrator privileges.
func UnsetSystem ¶
UnsetSystem removes a system environment variable. Requires administrator privileges.
Types ¶
type BackupData ¶
type BackupData struct {
CreatedAt time.Time `json:"created_at"`
Source string `json:"source"`
EnvVars []EnvVar `json:"env_vars"`
}
func LoadBackup ¶
func LoadBackup(filename string) (*BackupData, error)
type EnvVar ¶
EnvVar represents an environment variable with key and value.
func ListSystem ¶
ListSystem lists all system environment variables from registry.
func SearchSystem ¶
SearchSystem searches system env vars by keyword (case-insensitive, matches key or value).
func SearchUser ¶
SearchUser searches user env vars by keyword (case-insensitive, matches key or value).
type ExportFormat ¶
type ExportFormat string
const ( FormatShell ExportFormat = "sh" FormatBatch ExportFormat = "bat" FormatJSON ExportFormat = "json" )
func DetectFormat ¶
func DetectFormat(filename string) ExportFormat