update

package
v0.0.0-...-adf2613 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update provides functionality for self-updating the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Updater

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

Updater handles the self-update process.

It manages checking for updates on GitHub and applying them to the local executable.

Summary: Represents a Updater.

func NewUpdater

func NewUpdater(httpClient *http.Client, githubAPIURL string) *Updater

NewUpdater creates a new Updater.

Parameters:

  • httpClient: *http.Client. The HTTP client to use for network requests. If nil, http.DefaultClient is used.
  • githubAPIURL: string. Optional URL for the GitHub API (useful for Enterprise GitHub).

Returns:

  • *Updater: A new Updater instance.

Summary: Initializes NewUpdater operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Updater) CheckForUpdate

func (u *Updater) CheckForUpdate(ctx context.Context, owner, repo, currentVersion string) (*github.RepositoryRelease, bool, error)

CheckForUpdate checks for a new release on GitHub.

It compares the provided current version tag with the latest release tag on the repository.

Parameters:

  • ctx: context.Context. The context for the request.
  • owner: string. The GitHub repository owner (e.g., "mcpany").
  • repo: string. The GitHub repository name (e.g., "core").
  • currentVersion: string. The current version tag of the application.

Returns:

  • *github.RepositoryRelease: The release information if an update is available, nil otherwise.
  • bool: True if a newer version is available, false otherwise.
  • error: An error if the check fails (e.g., network error, API rate limit).

Summary: Executes CheckForUpdate operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

func (*Updater) UpdateTo

func (u *Updater) UpdateTo(ctx context.Context, fs afero.Fs, executablePath string, release *github.RepositoryRelease, assetName, checksumsAssetName string) error

UpdateTo downloads the new release, verifies its checksum, and replaces the current executable.

It handles downloading artifacts, verifying SHA256 checksums, and safely swapping the binary.

Parameters:

  • ctx: context.Context. The context for the request.
  • fs: afero.Fs. The file system abstraction (usually afero.NewOsFs()).
  • executablePath: string. The path to the currently running executable to replace.
  • release: *github.RepositoryRelease. The release object to update to.
  • assetName: string. The name of the binary asset to download.
  • checksumsAssetName: string. The name of the checksums file asset.

Returns:

  • error: An error if any step of the update process fails (download, verify, replace).

Side Effects:

  • Writes temporary files to disk.
  • Modifies the executable file on disk.

Summary: Executes UpdateTo operation.

Parameters:

  • TODO: Document parameters.

Returns:

  • TODO: Document returns.

Errors:

  • TODO: Document errors.

Side Effects:

  • None.

Jump to

Keyboard shortcuts

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