config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJDKExists            = errors.New("JDK already exists")
	ErrJDKNotFound          = errors.New("JDK not found")
	ErrInvalidPath    error = errors.New("Invalid Java installation path")
	ErrNotInitialized       = errors.New("jenvnot initialized")
)

Functions

func BackupEnvPath

func BackupEnvPath() error

BackupEnvPath creates a backup of the PATH environment variables On Windows, it backs up both user and system PATH variables

func CreateSymlink(source, target string) error

CreateSymlink creates a symbolic link from source to target

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the path to the config file

func GetDefaultBackupFilePath

func GetDefaultBackupFilePath() string

func GetDefaultSymlinkPath

func GetDefaultSymlinkPath() string

func InitializeConfig

func InitializeConfig(configFilePath string) error

InitializeConfig 初始化配置文件,如果配置文件不存在则创建

func ResetConfig

func ResetConfig()

func RestorePathFromBackup

func RestorePathFromBackup() error

RestorePathFromBackup restores PATH environment variables from backup

func SetConfigPath

func SetConfigPath(path string)

SetConfigPath sets a custom path for the config file

func ValidateJavaPath

func ValidateJavaPath(path string) bool

保留原有的工具函数

Types

type Config

type Config struct {
	Current       string         `json:"current"`
	SymlinkPath   string         `json:"symlink_path"`
	Initialized   bool           `json:"initialized"`
	EnvBackUpPath string         `json:"env_backup_path"`
	Jdks          map[string]JDK `json:"jdks"`  // 将数组改为 map
	Theme         string         `json:"theme"` // Current theme name
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() (*Config, error)

GetInstance 返回配置的单例实例

func (*Config) AddJDK

func (c *Config) AddJDK(name, path string) error

AddJDK 添加新的JDK

func (*Config) RemoveJDK

func (c *Config) RemoveJDK(name string) error

RemoveJDK 移除JDK

func (*Config) Save

func (c *Config) Save() error

func (*Config) SetCurrentJDK

func (c *Config) SetCurrentJDK(jdkName string) error

SetCurrentJDK 设置当前JDK

func (*Config) SetSymlinkPath

func (c *Config) SetSymlinkPath(symlinkPath string)

SetSymlinkPath 设置符号链接路径

type JDK

type JDK struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

type PathBackup

type PathBackup struct {
	UserPath   string `json:"user_path,omitempty"`
	SystemPath string `json:"system_path,omitempty"`
}

PathBackup represents the structure for backing up PATH environment variables

Jump to

Keyboard shortcuts

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