core

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

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

Variables

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

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

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

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

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

Functions

func GetAllLanguage

func GetAllLanguage() []string

func GetConfigPath added in v0.0.4

func GetConfigPath() string

func RegisterLanguage

func RegisterLanguage(lang Language)

Types

type Config added in v0.0.4

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

func GetConfig added in v0.0.4

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 added in v0.0.4

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
}

Jump to

Keyboard shortcuts

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