selfupdate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Copyright © 2022 Diego Morales <dgmorales@gmail.com>

Index

Constants

View Source
const (
	IsLatest   updateDecision = 0
	CanUpdate  updateDecision = 1
	MustUpdate updateDecision = 2
)

won't use iota bellow because values matter

Variables

This section is empty.

Functions

func Check

func Check(i *CliInfo, gh *github.Client) (updateDecision, error)

checkVersion checks if current version can or must be updated

check is internal and meant to be easily testable It is OK for the version information on cliInfo to be unset (nil), maybe because of previous errors parsing it. That is a noop and will return IsLatest and nil error on that case.

It does return error on some very abnormal cases (gross programming errors)

func DownloadAndApply

func DownloadAndApply(i CliInfo, gh *github.Client)

func NewClient

func NewClient() *github.Client

NewClient creates a new GitHub client

func StringToVersionHookFunc

func StringToVersionHookFunc(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error)

StringToVersionHookFunc is a mapstructure HookFunc to convert a string to a hashicorp/go-version Version pointer

This will be passed to mapstructure.Decoder and called for every field in the source structure being mapped, so we must "passthrough" if the field types don't match

func Uncompress

func Uncompress(filename string) (io.Reader, func(), error)

Types

type CliInfo

type CliInfo struct {
	RepositoryOwner        string
	RepositoryName         string
	MinimalRequiredVersion *semver.Version
	LatestVersion          *semver.Version
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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