Skip to content

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

License

Notifications You must be signed in to change notification settings

sg0hsmt/goversion

Repository files navigation

goversion

Go Reference Test Go Report Card codecov License Release

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

Requirements

Go 1.11 or later

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)
	}
}

Test

go test .

You can use GitHub Actions locally by act.

act -j test

Limitations

The development version (called gotip) is not supported.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages