api

package
v0.0.0-...-afe2e73 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2018 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BucketCache enables and disables caching of the bucket's
	// response. This ensures that if check-go-version is run
	// multiple times by a build we're not hitting Google's
	// API for each invocation.
	BucketCache = true

	// BucketCacheTime is the amount of time to keep bucket information
	// cached.
	BucketCacheTime = time.Minute * 30

	// BucketCacheFile is the location to cache bucket information. By default
	// this will be ~/.cache/check-go-version/bucket.json unless it's
	// overridden.
	BucketCacheFile = ""

	// BucketTimeout represents the amount of time we're willing to spend
	// retrieving information from the golang bucket.
	BucketTimeout = time.Minute * 5
)
View Source
var (
	// RegexSemanticVersion extracts version information for a posted
	// release. This does not include the qualifier such as 'alpha', 'beta',
	// etc.
	RegexSemanticVersion = regexp.MustCompile(`^go(\d+\.\d+(\.\d+|)).+$`)

	// RegexFullVersion extracts the full version information. Unlike
	// RegexSemanticVersion this will include the qualifiers such as
	// 'alpha', 'beta', etc.
	RegexFullVersion = regexp.MustCompile(`^go(\d+\.\d+[a-z0-9]*(\.\d[a-z0-9]*|)).+$`)
)

Functions

func CheckLatest

func CheckLatest(running *Version, latest *Version) bool

CheckLatest will return true if the latest version is the same as the currently running version.

func GetBucketObjects

func GetBucketObjects() ([]*storage.ObjectAttrs, error)

GetBucketObjects queries the golang bucket in Google Object Store and returns the versions present as a list.

Types

type Version

type Version struct {
	// Name is the complete name of the version excluding the original
	// suffix (ex. go1.9.2rc2.windows-386 instead of go1.9.2rc2.windows-386.msi)
	Name string

	// Version is the version excluding qualifiers such as 'beta1'. For
	// example if FullVersion is 'go1.4rc2` then FullVersion is '1.4'.
	Version semver.Version

	// FullVersion contains the complete version information include the semantic
	// version.
	FullVersion string

	// Platform is the generic platform (ex. windows, darwin, linux)
	Platform string

	// Architecture is the architecture of the binary. (ex. amd64, 386)
	Architecture string
}

Version returns specific information about a Go version.

func GetLatestRelease

func GetLatestRelease() (*Version, error)

GetLatestRelease returns a *Version struct matching the latest release for the currently running platform.

func GetReleaseVersions

func GetReleaseVersions() ([]*Version, error)

GetReleaseVersions calls GetVersions and removes any version that is a 'non-release' version. Basically this returns all versions except those that are alpha/beta/etc. This does not provide any platform specific filtering.

func GetRunningVersion

func GetRunningVersion() (*Version, error)

GetRunningVersion constructs and returns a *Version struct for the currently running instance of Go.

func (*Version) String

func (v *Version) String() string

String returns a human readable string representing this struct.

type Versions

type Versions []*Version

Versions is a list of Version structs that have the added benefit of being sortable.

func FilterVersionsToPlatform

func FilterVersionsToPlatform(versions Versions) Versions

FilterVersionsToPlatform acts as a filter and returns all versions that are matching the current platform.

func GetReleaseVersionsForPlatform

func GetReleaseVersionsForPlatform() (Versions, error)

GetReleaseVersionsForPlatform calls GetReleaseVersions() and filters the results so only releases matching the current platform are returned.

func GetVersions

func GetVersions() (Versions, error)

GetVersions returns a list of golang releases. This function will ignore any object returned from GetBucketObjects() that matches one or more of the following conditions:

  • Name of object starts with getgo/ - Ignored because this tool assumes you already have go installed. These objects also don't contain any version information.
  • Content type of objects starts with text/plain - Ignored because they are not actually releases (typically sha256 sums).
  • Is a signature instead of a release.
  • Appears to be a source rather than a release.

func (Versions) Len

func (vs Versions) Len() int

func (Versions) Less

func (vs Versions) Less(a int, b int) bool

func (Versions) Swap

func (vs Versions) Swap(a int, b int)

Jump to

Keyboard shortcuts

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