version

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "dev"
	Commit    = "unknown"
	Date      = "unknown"
	BuiltBy   = "unknown"
	GoVersion = runtime.Version()
	Platform  = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
)

Build information set by ldflags

Functions

func IsUpdateAvailable

func IsUpdateAvailable(ctx context.Context, repository string) (bool, error)

IsUpdateAvailable checks if an update is available without detailed info

Types

type GitHubRelease

type GitHubRelease struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"`
	Draft       bool      `json:"draft"`
	Prerelease  bool      `json:"prerelease"`
	PublishedAt time.Time `json:"published_at"`
	HTMLURL     string    `json:"html_url"`
}

GitHubRelease represents a GitHub release

type Info

type Info struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	Date      string `json:"date"`
	BuiltBy   string `json:"built_by"`
	GoVersion string `json:"go_version"`
	Platform  string `json:"platform"`
}

Info contains version information

func GetInfo

func GetInfo() Info

GetInfo returns version information

func (Info) JSON

func (i Info) JSON() (string, error)

JSON returns version information as JSON

func (Info) String

func (i Info) String() string

String returns a formatted version string

type SelfUpdater

type SelfUpdater struct {
	// Repository is the GitHub repository
	Repository string

	// HTTPClient is the HTTP client to use
	HTTPClient *http.Client

	// Platform is the target platform
	Platform string

	// Architecture is the target architecture
	Architecture string
}

SelfUpdater handles self-updating the binary

func NewSelfUpdater

func NewSelfUpdater(repository string) *SelfUpdater

NewSelfUpdater creates a new self-updater

func (*SelfUpdater) Update

func (su *SelfUpdater) Update(ctx context.Context, version string) error

Update updates the binary to the latest version

type UpdateChecker

type UpdateChecker struct {
	// CurrentVersion is the current version
	CurrentVersion string

	// Repository is the GitHub repository (e.g., "user/gh-notif")
	Repository string

	// HTTPClient is the HTTP client to use
	HTTPClient *http.Client

	// CheckInterval is how often to check for updates
	CheckInterval time.Duration

	// LastCheck is when we last checked for updates
	LastCheck time.Time
}

UpdateChecker checks for updates

func NewUpdateChecker

func NewUpdateChecker(repository string) *UpdateChecker

NewUpdateChecker creates a new update checker

func (*UpdateChecker) CheckForUpdate

func (uc *UpdateChecker) CheckForUpdate(ctx context.Context) (*UpdateInfo, error)

CheckForUpdate checks for a newer version

type UpdateInfo

type UpdateInfo struct {
	CurrentVersion string    `json:"current_version"`
	LatestVersion  string    `json:"latest_version"`
	ReleaseURL     string    `json:"release_url"`
	ReleaseNotes   string    `json:"release_notes"`
	PublishedAt    time.Time `json:"published_at"`
}

UpdateInfo contains information about an available update

func (*UpdateInfo) String

func (ui *UpdateInfo) String() string

String returns a formatted update message

Jump to

Keyboard shortcuts

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