goversion

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 10 Imported by: 1

README

goversion

pkg.go.dev

goversion provides utilities for versioning in Go.

CLI

$ go install github.com/tenntenn/goversion/cmd/golatest@latest
$ golatest
go1.24.2

Pacakge

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/tenntenn/goversion"
)

func main() {
	// fetch latest go version via "https://go.dev/VERSION?m=text"
	ctx := context.Context()
	latest, err := goversion.FetchLatest(ctx)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error:", err)
		os.Exit(1)
	}
	fmt.Println(latest.Version, latest.Time)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

func NewFetcher

func NewFetcher() *Fetcher

func (*Fetcher) FetchLatest

func (f *Fetcher) FetchLatest(ctx context.Context) (*Latest, error)

func (*Fetcher) SetHTTPClient

func (f *Fetcher) SetHTTPClient(httpClient *http.Client)

func (*Fetcher) SetPlaygroundURL added in v0.1.4

func (f *Fetcher) SetPlaygroundURL(url string)

func (*Fetcher) SetURL

func (f *Fetcher) SetURL(url string)

type Latest

type Latest struct {
	Version string
	Time    time.Time
	Source  Source
}

func FetchLatest

func FetchLatest(ctx context.Context) (*Latest, error)

type Source added in v0.1.4

type Source string
const (
	SourceGoDotDev   Source = "go.dev"
	SourcePlayground Source = "play.golang.org"
)

Directories

Path Synopsis
cmd
golatest command