utilities

package
v0.0.0-...-5f25c38 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bintime

func Bintime(bin string, to string) (t time.Time)

async get the modification time of a filesystem file: Bintime returns the modification time of a file or directory.

func Cut

func Cut(s, sep string) (before, after string, found bool)

Cut is strings.Cut

func ExtractToolNameFromURL

func ExtractToolNameFromURL(url string) string

func FatalHandler

func FatalHandler(err error) error

func FilenameToAssetFilters

func FilenameToAssetFilters(filename string) []string

FilenameToAssetFilters takes a filename string and returns a list of inclusive asset filters based on the filename it's used to avoid the need for prompting the user to select an asset on subsequent runs after having selected an asset on the first download.

func FindChecksumAsset

func FindChecksumAsset(asset Asset, assets []Asset) Asset

searches for an asset thaat has the same name as the requested one but ending with .sha256 or .sha256sum

func GetCurrentDirectory

func GetCurrentDirectory() string

func GetRename

func GetRename(file string, nameguess string) string

GetRename attempts to guess what to rename 'file' to for an appropriate executable name.

func IsDefinitelyNotExec

func IsDefinitelyNotExec(file string) bool

IsDefinitelyNotExec returns true if the file is definitely not an executable.

func IsDirectory

func IsDirectory(path string) bool

IsDirectory returns true if the file at 'path' is a directory.

func IsErrorNotOf

func IsErrorNotOf(err error, errorCompare error) bool

IsErrorNotOf returns true if err is not nil and is not of the type errorCompare.

func IsErrorOf

func IsErrorOf(err error, errorCompare error) bool

IsErrorOf returns true if err is not nil and is of the type errorCompare.

func IsExec

func IsExec(file string, mode os.FileMode) bool

IsExec returns true if the file is an executable based on the file name or the file mode (executable bit).

func IsGithubURL

func IsGithubURL(s string) bool

IsGithubURL returns true if s is a URL with github.com as the host.

func IsInvalidGithubURL

func IsInvalidGithubURL(s string) bool

func IsLocalFile

func IsLocalFile(s string) bool

IsLocalFile returns true if the file at 's' exists.

func IsNonGithubURL

func IsNonGithubURL(s string) bool

func IsURL

func IsURL(s string) bool

IsURL returns true if s is a valid URL.

func IsValidRepositoryReference

func IsValidRepositoryReference(s string) bool

IsValidRepositoryReference returns true if s is a valid repository reference in the form of "owner/repo".

func ModeFrom

func ModeFrom(fname string, mode fs.FileMode) fs.FileMode

ModeFrom returns the mode with the executable bit set if the file is an executable.

func RepositoryNameFromGithubURL

func RepositoryNameFromGithubURL(s string) (name string, found bool)

func SameImplementedInterface

func SameImplementedInterface(a, b any) bool

check if two interfaces implement the same type

func SetIf

func SetIf[T interface{}](condition bool, original T, newValue T) T

SetWhen returns the newValue if condition is true, otherwise it returns the original value. use generics like <T interface{}> to make this function more flexible

Types

type InvalidGitHubProjectReference

type InvalidGitHubProjectReference = error

func NewInvalidGitHubProjectReferenceError

func NewInvalidGitHubProjectReferenceError(reference string) InvalidGitHubProjectReference

type InvalidGitHubProjectURLError

type InvalidGitHubProjectURLError = error
var InvalidGitHubProjectURL InvalidGitHubProjectURLError = errors.New("Invalid GitHub URL").(InvalidGitHubProjectURLError)

func NewInvalidGitHubProjectURLError

func NewInvalidGitHubProjectURLError(_ string) InvalidGitHubProjectURLError

type RepositoryReference

type RepositoryReference struct {
	Owner string
	Name  string
}

func ParseRepositoryReference

func ParseRepositoryReference(s string) (*RepositoryReference, error)

func (*RepositoryReference) String

func (rr *RepositoryReference) String() string

Jump to

Keyboard shortcuts

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