core

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ContextLogWriterKey ctxKey = "context.log.writer"
)

Variables

View Source
var GetLanguage = func(name string) (Language, bool) {
	langRWMutex.RLock()
	lang, exists := languages[name]
	langRWMutex.RUnlock()
	return lang, exists
}
View Source
var GetRootDir = func() string {

	if custom := os.Getenv("XVM_ROOT"); custom != "" {
		if !strings.Contains(custom, " ") {
			ensureDir(custom)
			return custom
		}
	}

	if dataHome := os.Getenv("XDG_DATA_HOME"); dataHome != "" {
		path := filepath.Join(dataHome, defaultDir)
		if !strings.Contains(path, " ") {
			ensureDir(path)
			return path
		}
	}

	if homeDir, err := os.UserHomeDir(); err == nil && homeDir != "" {
		path := filepath.Join(homeDir, ".local", "share", defaultDir)
		if !strings.Contains(path, " ") {
			ensureDir(path)
			return path
		}
	}

	if cfgDir, err := os.UserConfigDir(); err == nil && cfgDir != "" {
		path := filepath.Join(cfgDir, defaultDir)
		if !strings.Contains(path, " ") {
			ensureDir(path)
			return path
		}
	}

	if home := os.Getenv("HOME"); home != "" {
		path := filepath.Join(home, defaultDir)
		if !strings.Contains(path, " ") {
			ensureDir(path)
			return path
		}
	}

	fallback := filepath.Join("/opt", "xvm")
	ensureDir(fallback)
	return fallback
}
View Source
var Version = "1.0.0-dev"

Functions

func GetAllLanguage

func GetAllLanguage() []string

func GetConfigPath

func GetConfigPath() string

func RegisterLanguage

func RegisterLanguage(lang Language)

Types

type Config

type Config struct {
	Language string         `json:"language"`
	Addon    []LanguageItem `json:"addon"`
}

func GetConfig

func GetConfig() *Config

type InstalledVersion

type InstalledVersion struct {
	Version  *version.Version
	Origin   string
	Location string
}

type Language

type Language interface {
	Name() string
	ListRemoteVersions(ctx context.Context) ([]*RemoteVersion, error)
	ListInstalledVersions(ctx context.Context) ([]*InstalledVersion, error)
	SetDefaultVersion(ctx context.Context, version string) error
	GetDefaultVersion(ctx context.Context) *InstalledVersion
	Install(ctx context.Context, remoteVersion *RemoteVersion) error
	Uninstall(ctx context.Context, version string) error
}

type LanguageItem

type LanguageItem struct {
	Name           string `json:"name"`
	Provider       string `json:"provider"`
	DataSourceName string `json:"dsn"`
}

type RemoteVersion

type RemoteVersion struct {
	Version *version.Version
	Origin  string
	Comment string
}

Source Files

  • config.go
  • interface.go
  • registry.go

Jump to

Keyboard shortcuts

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