Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpgradeBackground ¶
func UpgradeBackground(ctx context.Context, packagePath string) <-chan *UpgradeResult
UpgradeBackground runs Upgrade in a goroutine and returns a channel that will receive the UpgradeResult. The channel is closed after the result is sent. This allows for non-blocking upgrade operations. The context can be used to cancel the upgrade operation.
Types ¶
type UpgradeResult ¶
type UpgradeResult struct {
CurrentInfo *debug.BuildInfo // Current build information of the running process, if available
ExitError error // Error encountered during the upgrade process, if any
// contains filtered or unexported fields
}
UpgradeResult contains the result of an upgrade operation. It provides access to build information from both the current process and the newly installed binary.
func Upgrade ¶
func Upgrade(ctx context.Context, packagePath string) *UpgradeResult
Upgrade attempts to upgrade the current binary to the latest version using 'go install'. The packagePath parameter specifies the relative path from the module root to the package. Upgrade is skipped if the current version is a development build or build info is unavailable. Context cancellation can be used to kill the go install process.
func (*UpgradeResult) DidUpgrade ¶
func (u *UpgradeResult) DidUpgrade() bool
DidUpgrade returns false if the upgrade did not occur, this can happen when the build information is not available, the current version is a development version, or upgrade was not necessary (e.g., already at latest version).
func (*UpgradeResult) NewBuildInfo ¶
func (u *UpgradeResult) NewBuildInfo() (*debug.BuildInfo, error)
NewBuildInfo returns the build information of the newly installed binary. Returns nil if the executable path cannot be determined or the build info cannot be read.