Skip to content

Simple package that retrieves the latest stable release version of Go.

License

Notifications You must be signed in to change notification settings

KEINOS/go-relver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-relver - Retrieve the latest Go version

go1.22+ GoDoc License

A simple Go package to fetch the latest and stable release version of Go.

Usage

$ # Install the module
$ go get github.com/KEINOS/go-relver
...
// Use the package
import "github.com/KEINOS/go-relver/relver"
// Examples
import "github.com/KEINOS/go-relver/relver"

func Example() {
    // Get the latest release version of Go
    goVerLatest, err := relver.Get()
    if err != nil {
        log.Panic(err)
    }

    fmt.Println(goVerLatest)
    // Output: go1.23.2
}

func Example_set_request_timeout() {
    // Set the request timeout to 10 seconds.
    // Default is 5 seconds.
    relver.SetTimeout(10)

    goVerLatest, err := relver.Get()
    if err != nil {
        log.Panic(err)
    }

    fmt.Println(goVerLatest)
    // Output: go1.23.2
}

func Example_compare_go_versions() {
    goVerLatest, err := relver.Get()
    if err != nil {
        log.Panic(err)
    }

    // Get the local Go version
    goVerLocal := runtime.Version()

    // Compare the two Go versions
    if relver.Compare(goVerLatest, goVerLocal) > 0 {
        fmt.Println("You are using an outdated Go version.")
    } else {
        fmt.Println("You are using the latest Go version.")
    }
    //
    // Output: You are using an outdated Go version.
}

License

License

Contributing

go1.22+ GoDoc

  • Any feedbacks for the improvement are welcome!
  • Branch to PR: main <- feature/your-idea
  • Bug report: Open an issue with a simple code that reproduces the issue. That helps a lot.

Statuses

Basic Tests CodeQL Dependabot Updates Go Report Card codecov

About

Simple package that retrieves the latest stable release version of Go.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Languages