gvm

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

README

gvm

gvm is a Go version manager. gvm installs a Go version and prints the commands to configure your environment to use it. gvm can install Go binary versions from https://storage.googleapis.com/golang or build it from source. Below are examples for common shells.

bash:

eval "$(gvm 1.21.0)"

cmd.exe (for batch scripts %i should be substituted with %%i):

FOR /f "tokens=*" %i IN ('"gvm.exe" 1.21.0') DO %i

powershell:

gvm --format=powershell 1.21.0 | Invoke-Expression

gvm flags can be set via environment variables by setting GVM_<flag>. For example --http-timeout can be set via GVM_HTTP_TIMEOUT=10m.

Installation

You can download a binary release of gvm for your specific platform from the releases page. Then just put the binary in your PATH and mark it as executable (chmod +x gvm).

You must adjust the version and platform info in URLs accordingly.

Linux (amd64):

# Linux Example (assumes ~/bin is in PATH).
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-linux-amd64
chmod +x ~/bin/gvm
eval "$(gvm 1.21.0)"
go version

Linux (arm64):

# Linux Example (assumes ~/bin is in PATH).
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-linux-arm64
chmod +x ~/bin/gvm
eval "$(gvm 1.21.0)"
go version

macOS (universal):

# macOS Example
curl -sL -o /usr/local/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-darwin-all
chmod +x /usr/local/bin/gvm
eval "$(gvm 1.21.0)"
go version

Windows (PowerShell):

[Net.ServicePointManager]::SecurityProtocol = "tls12"
Invoke-WebRequest -URI https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-windows-amd64.exe -Outfile C:\Windows\System32\gvm.exe
gvm --format=powershell 1.21.0 | Invoke-Expression
go version

Fish Shell:

Use gvm with fish shell by executing gvm 1.21.0 | source in lieu of using eval.

For existing Go users:

go install github.com/andrewkroh/gvm/cmd/gvm@v0.5.2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailableVersion added in v0.3.1

type AvailableVersion struct {
	Version *GoVersion
	Source  bool // Available to install from source.
	Binary  bool // Available to download as a binary.
}

func (AvailableVersion) String added in v0.3.1

func (av AvailableVersion) String() string

type GoVersion

type GoVersion struct {
	// contains filtered or unexported fields
}

func MustParseVersion added in v0.5.0

func MustParseVersion(in string) *GoVersion

MustParseVersion parses the given Go version to return a GoVersion. Otherwise, it panics.

func ParseVersion

func ParseVersion(in string) (*GoVersion, error)

func (*GoVersion) IsTip

func (v *GoVersion) IsTip() bool

func (*GoVersion) LessThan

func (v *GoVersion) LessThan(v2 *GoVersion) bool

func (*GoVersion) Prerelease

func (v *GoVersion) Prerelease() bool

func (*GoVersion) Stable

func (v *GoVersion) Stable() bool

func (*GoVersion) String

func (v *GoVersion) String() string

func (*GoVersion) VendorSupport

func (v *GoVersion) VendorSupport() (has, experimental bool)

type Manager

type Manager struct {
	// GVM Home directory. Defaults to $HOME/.gvm
	Home string

	// GOOS settings. Defaults to current OS.
	GOOS string

	// GOARCH setting. Defaults to the current architecture.
	GOARCH string

	// Golang binary store URL. Used to download listing and go binaries.
	// Defaults to https://storage.googleapis.com/golang
	GoStorageHome string

	// GoSourceURL configres the update git repository to download and update local
	// source checkouts from.
	// Defaults to https://go.googlesource.com/go
	GoSourceURL string

	HTTPTimeout time.Duration

	Logger logrus.FieldLogger
	// contains filtered or unexported fields
}

func (*Manager) Available

func (m *Manager) Available() ([]AvailableVersion, error)

func (*Manager) AvailableBinaries

func (m *Manager) AvailableBinaries() ([]*GoVersion, error)

func (*Manager) AvailableSource

func (m *Manager) AvailableSource() ([]*GoVersion, error)

func (*Manager) Build

func (m *Manager) Build(version *GoVersion) (string, error)

func (*Manager) HasVersion

func (m *Manager) HasVersion(version *GoVersion) (bool, error)

HasVersion checks if a given go version is installed

func (*Manager) Init

func (m *Manager) Init() error

func (*Manager) Install

func (m *Manager) Install(version *GoVersion) (string, error)

func (*Manager) Installed

func (m *Manager) Installed() ([]*GoVersion, error)

Installed returns all installed go version

func (*Manager) Remove

func (m *Manager) Remove(version *GoVersion) error

func (*Manager) UpdateCache

func (m *Manager) UpdateCache() error

func (*Manager) VersionGoROOT

func (m *Manager) VersionGoROOT(version *GoVersion) string

VersionGoROOT returns the GOROOT path for a go version. VersionGoROOT does not check if the version is installed.

Directories

Path Synopsis
cmd
gvm

Jump to

Keyboard shortcuts

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