utils

package
v0.4.26 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(filepath string, url string) error

func GetHome

func GetHome() string

GetHome returns the home path

func GetLatestReleaseTagsSorted added in v0.4.25

func GetLatestReleaseTagsSorted(org string, repo string) ([]string, error)

func ReadFileSource

func ReadFileSource(uri string) (string, error)

ReadFileSource supports "http", "https", and "file" protocols. It takes in the location as a URI and returns the contents of the file as a string.

func ReadLocalFile

func ReadLocalFile(location string) (string, error)

ReadLocalFile takes in the location of a local file in the format `file://location/of/file` and returns the content of the file if the path is valid and no error occurs.

func ReadRemoteFile

func ReadRemoteFile(url string) (string, error)

ReadRemoteFile takes in the location of a remote file in the format 'http://location/of/file' or 'https://location/file' and returns the content of the file if the location is valid and no error occurs.

func SortDottedStringsByDigits added in v0.4.25

func SortDottedStringsByDigits(s []string) []string

SortDottedStringsByDigits takes version-like dot separated digits in string format and returns them in sorted normalized form. Takes [v1.4.3,0.9.3,v0.0.0]=> returns [v0.0.0,0.9.3,v1.4.3] This function ignores all letters except for: - numeric digits - alpha, beta, rc, stable For the same version, stable is preferred over edge.

Types

type JSONMarshaller added in v0.4.21

type JSONMarshaller struct{}

func (*JSONMarshaller) Marshal added in v0.4.21

func (j *JSONMarshaller) Marshal(obj interface{}) (string, error)

func (*JSONMarshaller) Unmarshal added in v0.4.21

func (j *JSONMarshaller) Unmarshal(obj string, result interface{}) error

type Marshaller added in v0.4.21

type Marshaller interface {
	Marshal(interface{}) (string, error)
}

type Unmarshaller added in v0.4.21

type Unmarshaller interface {
	Unmarshal(string, interface{}) error
}

Jump to

Keyboard shortcuts

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