Documentation ¶
Index ¶
- Variables
- func CurrentVersion() (string, error)
- func Determine(version string, mode Mode) (path, ver string, err error)
- func DetermineFromModuleGoVersion(mode Mode) (path, ver string, _ error)
- func Lookup(version string) (string, error)
- func LookupLatest(version string) (string, error)
- func MajorVersion(version string) string
- func ModuleGoVersion() (string, error)
- func StableVersion(version string) (bool, error)
- func ValidModuleGoVersion(version string) error
- func ValidVersion(version string) error
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidVersion = errors.New("invalid version")
var ErrNotFound = exec.ErrNotFound
var ErrUnexpectedGoVersion = errors.New("unexpected go version in go.mod")
Functions ¶
func CurrentVersion ¶ added in v0.0.3
CurrentVersion returns the version of "go" command.
func Determine ¶ added in v1.0.0
Determine go command with given version, and return its path and actual version. Following mode is available.
- ModeExact determines command by using Lookup
- ModeLatest determines command by using LookupLatest
- ModeFallback determines command by using LookupLatest, but if no command was found, fallbacks to "go" command
func DetermineFromModuleGoVersion ¶ added in v1.0.0
DetermineFromModuleGoVersion determines go command with the version from go.mod, and returns its path and actual version. Every mode uses LookupLatest. In ModeFallback, if no command was found, fallbacks to "go"command.
func Lookup ¶
Lookup finds a go executable having exact given version. Firstly, it checks the given version with ValidVersion, and returns ErrInvalidVersion if the version is invalid. After that, it checks versions of "go" and specific executable(golang.org/dl/go1.N). When an executable with GOVERSION={given version} exists, it returns the executable's path. If no executable exists, it returns ErrNotFound.
func LookupLatest ¶
LookupLatest finds a go executable having the given version. Behavior is similar to Lookup, but it collects versions that have the same major version. This finds the executable that has the latest version in the collected list. If "go" command has the same major version, it is prioritized.
func MajorVersion ¶ added in v0.0.4
MajorVersion returns major version of the given version. If the given version is invalid, returned value is an empty string.
func ModuleGoVersion ¶ added in v0.0.2
ModuleGoVersion reads module's go version from "go.mod" with the path from `go env GOMOD`.
func StableVersion ¶
StableVersion returns whether the given go version exists and is stable. The source of correctness is the following URL:
https://go.dev/dl/?mode=json&include=all
func ValidModuleGoVersion ¶
ValidModuleGoVersion compares the given version and module's Go version. Go version of the module will be read from "go.mod" with the path from `go env GOMOD`.
func ValidVersion ¶
ValidVersion returns whether the given go version exists. The source of correctness is the following URL:
https://go.dev/dl/?mode=json&include=all