Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionString string = "1.0.3"
)

Variables

This section is empty.

Functions

func Map added in v1.0.0

func Map[S ~[]E, E any, V any](ts S, fn func(E) V) []V

Map applies a given function to each element of a slice and returns a new slice with the results.

Types

type ComparisonResult added in v1.0.3

type ComparisonResult int

ComparisonResult represents the result of comparing two values.

const (

	// LessThan indicates that the first value is less than the second in a comparison operation.
	LessThan ComparisonResult = iota

	// Equal indicates that the first value is equal to the second in a comparison operation.
	Equal

	// GreaterThan indicates that the first value is greater than the second in a comparison operation.
	GreaterThan
)

type GitHubClient added in v0.10.0

type GitHubClient interface {
	QueryLatestReleaseTag(ctx context.Context) (*GithubRelease, error)
}

GitHubClient is an interface for interacting with GitHub's API, specifically for querying the latest release tag of a repository.

func NewGitHubApiClient

func NewGitHubApiClient(httpClient HttpClient, config ...HttpClientOptionsFunc) GitHubClient

NewGitHubApiClient creates a new GitHubClient with customizable HTTP client options for querying GitHub's API.

type GithubRelease

type GithubRelease struct {
	Id          uint64    `json:"id"`
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	HtmlUrl     string    `json:"html_url"`
	PublishedAt time.Time `json:"published_at"`
}

GithubRelease represents a release from a GitHub repository, including essential metadata and URL for access.

func (GithubRelease) TryParseVersionFromTag

func (r GithubRelease) TryParseVersionFromTag() (*VersionInfo, error)

TryParseVersionFromTag attempts to extract and parse semantic version details from the TagName of a GitHub release.

type HttpClient added in v0.10.0

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient provides an interface for making HTTP requests, allowing for different implementations such as mocks or wrappers.

type HttpClientOptions

type HttpClientOptions struct {
	RequestTimeout time.Duration
}

HttpClientOptions holds configuration options for customizing the behavior of an HttpClient.

type HttpClientOptionsFunc

type HttpClientOptionsFunc func(*HttpClientOptions)

HttpClientOptionsFunc represents a function that modifies HttpClientOptions to customize HttpClient's behavior.

type VersionInfo

type VersionInfo struct {
	Major int
	Minor int
	Patch int
}

VersionInfo represents the version details using semantic versioning.

func ApplicationVersion

func ApplicationVersion() (*VersionInfo, error)

ApplicationVersion parses and returns the application's version information. If the version is not set, an error is returned.

func (VersionInfo) Compare added in v1.0.3

func (v VersionInfo) Compare(other VersionInfo) ComparisonResult

Compare compares the current VersionInfo instance with another VersionInfo instance and returns a ComparisonResult.

func (VersionInfo) Equal

func (v VersionInfo) Equal(other VersionInfo) bool

Equal determines if two VersionInfo instances represent the same version based on semantic versioning.

func (VersionInfo) LessThan

func (v VersionInfo) LessThan(other VersionInfo) bool

LessThan determines if the current VersionInfo is less than the specified VersionInfo based on semantic versioning.

func (VersionInfo) LessThanOrEqual added in v1.0.3

func (v VersionInfo) LessThanOrEqual(other VersionInfo) bool

LessThanOrEqual determines if the current VersionInfo is less than or equal to the specified VersionInfo based on semantic versioning.

func (VersionInfo) String

func (v VersionInfo) String() string

String returns the VersionInfo as a formatted string in the semantic versioning format (Major.Minor.Patch).

Jump to

Keyboard shortcuts

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