Documentation
¶
Index ¶
- Variables
- func AppendVersion(v Version) error
- func Bytes2string(bytes []byte) string
- func CheckVersion(v string) (string, bool)
- func ChooseDownloadURL(version string) (string, string, error)
- func CompareVersion(v1, v2 string) int
- func DefaultInstallation() (string, error)
- func DownloadProcessBar(length int64, description string, finishedTip string) *progressbar.ProgressBar
- func ErrPrintln(a ...any)
- func Extract(archive *os.File, target string) error
- func ExtractTarGzip(ctx context.Context, reader io.Reader, target string) error
- func ExtractZip(ctx context.Context, reader io.Reader, target string) error
- func GetCacheDir() (string, error)
- func GetConfigDir() (string, error)
- func GetHttpClient() (*http.Client, error)
- func GetInstallation() (string, error)
- func GetMirror() (string, error)
- func GetStoreDir() (string, error)
- func GetUsingVersion() (string, error)
- func GetVersionListAPI() (string, error)
- func MaxVersion(vs []string) string
- func OpenFile(filename string, flag int, perm os.FileMode) (*os.File, error)
- func Printf(format string, a ...any)
- func Println(a ...any)
- func String2bytes(s string) []byte
- func Tipf(format string, a ...any)
- func ToUnixPath(p string) string
- func UserHomeDir() (string, error)
- func Warnf(format string, a ...any)
- func WriteConfig(cfg *Config) error
- func WriteStore(storeData *Store) error
- type Config
- type GoVersion
- type Pair
- type Store
- type Version
Constants ¶
This section is empty.
Variables ¶
var Silence bool
Functions ¶
func AppendVersion ¶
func Bytes2string ¶
Bytes2string convert a byte slice to a string without allocating new memory.
func CheckVersion ¶
func CompareVersion ¶
func DefaultInstallation ¶
func DownloadProcessBar ¶
func DownloadProcessBar(length int64, description string, finishedTip string) *progressbar.ProgressBar
func ErrPrintln ¶ added in v1.1.0
func ErrPrintln(a ...any)
func Extract ¶
Extract extracts archive file to specified target path, only support .zip and .tar.gz
func ExtractTarGzip ¶
ExtractTarGzip extract tar.gz from reader and save to target.
func ExtractZip ¶
ExtractZip extract zip from reader and save to target.
func GetCacheDir ¶
func GetConfigDir ¶
func GetHttpClient ¶
func GetInstallation ¶
func GetStoreDir ¶
func GetUsingVersion ¶ added in v1.1.0
func GetVersionListAPI ¶
func MaxVersion ¶
func String2bytes ¶
String2bytes convert a string to a byte slice without allocating new memory.
func ToUnixPath ¶ added in v1.1.0
ToUnixPath converts Windows path to Unix-style path.
func UserHomeDir ¶
UserHomeDir returns the home directory for the current user.
func WriteStore ¶
Types ¶
type Config ¶
type Config struct {
// where to query Go versions, default https://go.dev/dl/?mode=json&include=all
ListAPI string `toml:"listapi" mapstructure:"listapi" comment:"where to query Go versions, default https://go.dev/dl/?mode=json&include=all"`
// download URL for Go release archive, default https://dl.google.com/go/
Mirror string `toml:"mirror" mapstructure:"mirror" comment:"where to download Go release archive, default https://dl.google.com/go/"`
// proxy for HTTP requests, default use system proxy
Proxy string `toml:"proxy" mapstructure:"proxy" comment:"http proxy, default use system proxy"`
// where to store cache and package, windows: %USERPROFILE%/AppData/Local/govm/root/ other: $HOME/.local/govm
Install string `` /* 154-byte string literal not displayed */
// using version
Use string `toml:"use" mapstructure:"use" comment:"using version"`
// contains filtered or unexported fields
}
func DefaultConfig ¶
DefaultConfig returns default config, only for config showing.
type Version ¶
type Version struct {
Filename string `toml:"filename" json:"filename"`
Os string `toml:"os" json:"os"`
Arch string `toml:"arch" json:"arch"`
Version string `toml:"version" json:"version"`
Sha256 string `toml:"sha256" json:"sha256"`
Size uint64 `toml:"size" json:"size"`
Kind string `toml:"kind" json:"kind"`
Path string `toml:"path"`
Using bool `toml:"-"`
Stable bool `toml:"-"`
}
func GetLocalVersions ¶
GetLocalVersions returns the local versions from store.
func GetRemoteVersion ¶
GetRemoteVersion returns all available go versions from versionURL without git. If unstable is false, it only returns stable versions, otherwise it returns all versions that includes unstable versions.