Documentation
¶
Index ¶
- func ContainsInt(needle int, haystack []int) bool
- func DedupeStrings(values []string, keyGetter ...StringKeyGetter) []string
- func Download(options DownloadOptions) error
- func EnsureDirectoryExists(pathToDirectory string) error
- func FindParentContainingChildDirectory(targetDirectoryName, startingFrom string, levels ...int) (string, error)
- func GetHttpCloneUrlFromHttpLink(httpLinkUrl string) (string, error)
- func GetHttpLinkFromHttpCloneUrl(httpCloneUrl string) (string, error)
- func GetHttpLinkFromSshCloneUrl(sshCloneUrl string) (string, error)
- func GetLocalSSHKeys(keysDirectory string) ([]string, map[string]string, error)
- func GetNKeyValuePairsStringMap(kvd map[string]string) int
- func GetSshCloneUrlFromHttpLinkUrl(httpLinkUrl string) (string, error)
- func GitClone(cloneURL, localPath string) error
- func GitInit(cloneURL, localPath string) error
- func HTTPGet(targetURL url.URL, headers map[string]string) (*http.Response, error)
- func IsDirectoryEmpty(pathToDirectory string) (bool, error)
- func IsEmptyString(test string) bool
- func IsPathType(pathInfo os.FileInfo, pathType PathType) bool
- func OpenURIWithDefaultApplication(targetURI string) error
- func PathExists(asType PathType, pathFragments ...string) (bool, error)
- func ResolvePath(relativePathFragments ...string) (string, error)
- func Untar(options UntarOptions) []error
- func Unzip(options UnzipOptions) []error
- type DownloadEvent
- type DownloadOptions
- type DownloadState
- type DownloadStatus
- type PathType
- type StringKeyGetter
- type UntarEvent
- type UntarOptions
- type UntarState
- type UntarStatus
- type UnzipEvent
- type UnzipOptions
- type UnzipState
- type UnzipStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsInt ¶
func DedupeStrings ¶ added in v0.1.1
func DedupeStrings(values []string, keyGetter ...StringKeyGetter) []string
func Download ¶
func Download(options DownloadOptions) error
Download downloads a file from the url in options.URL and places the content in the file at options.FilePath
Made possible with guidance from: https://golangcode.com/download-a-file-with-progress/
func EnsureDirectoryExists ¶ added in v0.1.18
EnsureDirectoryExists ensures that a directory exists at :pathToDirectory, returning an error only if a directory cannot be ensured to exist there
func FindParentContainingChildDirectory ¶ added in v0.0.4
func FindParentContainingChildDirectory(targetDirectoryName, startingFrom string, levels ...int) (string, error)
FindParentContainingChildDirectory continously ascends from the initial directory path at `startingFrom` and checks for the existence of a child directory named `targetDirectoryName` for `levels[0]` levels.
On successfully finding such a child directory, it returns the path of the parent directory as the first argument, on failing to find, it returns an empty string. In both cases, the returned `error`-typed argument will be nil.
If the function failed to complete, the second `error`-typed argument will be non-nil.
func GetLocalSSHKeys ¶ added in v0.0.13
func GetNKeyValuePairsStringMap ¶ added in v0.0.18
GetNKeyValuePairsStringMap returns the number of key-value mappings stored in the provided `kvd` (key-value dictionary)
func GitClone ¶ added in v0.1.9
GitClone does a `git clone` on the provided :cloneURL into the directory at :localPath. If the remote is a bare repository, a new repository will be initialised at :localPath with the `origin` remote set to :cloneURL
func IsDirectoryEmpty ¶ added in v0.1.18
IsDirectoryEmpty returns whether the provided directory located at :pathToDirectory is empty or not. If the error return is not nil, this indicates a system-type error
func IsEmptyString ¶ added in v0.0.16
func OpenURIWithDefaultApplication ¶
OpenURIWithDefaultApplication runs xdg-open on linux, open on macos, and rundll32.exe on windows with the provided :targetURI as an argument
func PathExists ¶ added in v0.0.16
func ResolvePath ¶ added in v0.0.14
func Untar ¶
func Untar(options UntarOptions) []error
Untar takes the .zip file located at options.InputPath and untars its contents to options.OutputPath; returns an error if something unexpected happened, or nil if all is well
Made possible with guidance from: https://medium.com/@skdomino/taring-untaring-files-in-go-6b07cf56bc07
func Unzip ¶
func Unzip(options UnzipOptions) []error
Unzip takes the .zip file located at options.InputPath and unzips its contents to options.OutputPath; returns an error if something unexpected happened, or nil if all is well
Made possible with guidance from: https://golangcode.com/unzip-files-in-go/
Types ¶
type DownloadEvent ¶
type DownloadEvent struct { State DownloadState `json:"download_state"` URL string `json:"url"` FilePath string `json:"file_path"` TempFilePath string `json:"temp_file_path"` Status *DownloadStatus `json:"status"` }
func (DownloadEvent) String ¶
func (de DownloadEvent) String() string
type DownloadOptions ¶
type DownloadState ¶
type DownloadState string
const ( DefaultEventsUpdateInterval = 500 * time.Millisecond DownloadStateStarting DownloadState = "download_starting" DownloadStateReport DownloadState = "download_report" DownloadStateError DownloadState = "download_error" DownloadStateFailed DownloadState = "download_failed" DownloadStateSuccess DownloadState = "download_success" )
type DownloadStatus ¶
type DownloadStatus struct { TotalBytes uint64 `json:"total_bytes"` ProcessedBytes uint64 `json:"processed_bytes"` }
func (DownloadStatus) GetPercentage ¶
func (ds DownloadStatus) GetPercentage() float64
type StringKeyGetter ¶ added in v0.1.1
type UntarEvent ¶
type UntarEvent struct { // State is a string code that indicates the underlying operation State UntarState // Path is a string indicating path to a file if it's non-empty Path string // Message is an arbitrary string Message string // Status should provide metadata on the underlying operation Status *UntarStatus }
UntarEvent is an object that is passed to the events stream for the consumer to know what's going on inside
type UntarOptions ¶
type UntarOptions struct { // Events, if populated, receives events for logging purposes Events chan UntarEvent // InputPath defines the path to the .zip file we want to untar InputPath string // OutputPath defines the path to a directory where the untarred files // should go OutputPath string // ReturnOnFileError indicates whether to return an error instantly // when an error is encountered ReturnOnFileError bool }
type UntarState ¶
type UntarState string
const ( UntarStateStarting UntarState = "untar_starting" UntarStateProcessing UntarState = "untar_processing" UntarStateError UntarState = "untar_error" UntarStateOK UntarState = "untar_ok" UntarStateStatus UntarState = "untar_status" UntarStateSuccess UntarState = "untar_success" UntarStateFailed UntarState = "untar_failed" )
type UntarStatus ¶
type UntarStatus struct { // BytesTotal is the total number of bytes to extract BytesTotal int64 // BytesProcessed is the number of bytes processed so far BytesProcessed int64 // FilesTotalCount is the total number of files to extract FilesTotalCount int // FilesProcessedCount is the number of files processed so far FilesProcessedCount int }
UntarStatus stores the status of the untarring process and is returned through the UntarEvent object
func (UntarStatus) GetPercentDoneByBytes ¶
func (us UntarStatus) GetPercentDoneByBytes() float64
func (UntarStatus) GetPercentDoneByFiles ¶
func (us UntarStatus) GetPercentDoneByFiles() float64
type UnzipEvent ¶
type UnzipEvent struct { // State is a string code that indicates the underlying operation State UnzipState // Path is a string indicating path to a file if it's non-empty Path string // Message is an arbitrary string Message string // Status should provide metadata on the underlying operation Status *UnzipStatus }
UnzipEvent is an object that is passed to the events stream for the consumer to know what's going on inside
type UnzipOptions ¶
type UnzipOptions struct { // Events, if populated, receives events for logging purposes Events chan UnzipEvent // InputPath defines the path to the .zip file we want to unzip InputPath string // OutputPath defines the path to a directory where the unzipped files // should go OutputPath string // ReturnOnFileError indicates whether to return an error instantly // when an error is encountered ReturnOnFileError bool }
type UnzipState ¶
type UnzipState string
const ( UnzipStateStarting UnzipState = "unzip_starting" UnzipStateProcessing UnzipState = "unzip_processing" UnzipStateError UnzipState = "unzip_error" UnzipStateOK UnzipState = "unzip_ok" UnzipStateStatus UnzipState = "unzip_status" UnzipStateSuccess UnzipState = "unzip_success" UnzipStateFailed UnzipState = "unzip_failed" )
type UnzipStatus ¶
type UnzipStatus struct { // BytesTotal is the total number of bytes to extract BytesTotal int64 // BytesProcessed is the number of bytes processed so far BytesProcessed int64 // FilesTotalCount is the total number of files to extract FilesTotalCount int // FilesProcessedCount is the number of files processed so far FilesProcessedCount int }
UnzipStatus stores the status of the unzipping process and is returned through the UnzipEvent object
func (UnzipStatus) GetPercentDoneByBytes ¶
func (us UnzipStatus) GetPercentDoneByBytes() float64
func (UnzipStatus) GetPercentDoneByFiles ¶
func (us UnzipStatus) GetPercentDoneByFiles() float64