Categorygithub.com/sg0hsmt/goversion
repositorypackage
0.1.3
Repository: https://github.com/sg0hsmt/goversion.git
Documentation: pkg.go.dev

# README

goversion

GoDoc Test Go Report Card codecov License Release

goversion is a package that gets the go version from the go command.

How to use

See godoc examples.

package main

import (
	"fmt"

	"github.com/sg0hsmt/goversion"
)

func main() {
	ver, err := goversion.Discover()
	if err != nil {
		fmt.Printf("discover failed: %v", err)
		return
	}

	fmt.Printf("version: %s\n", ver)
	fmt.Printf("major: %d\n", ver.Major)
	fmt.Printf("minor: %d\n", ver.Minor)
	fmt.Printf("patch: %d\n", ver.Patch)

	if ver.IsPreRelease() {
		fmt.Printf("pre: %q\n", ver.Pre)
	}
}

Limitations

The development version (called gotip) is not supported.