utils

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsInt

func ContainsInt(needle int, haystack []int) bool

func GetLocalSSHKeys added in v0.0.13

func GetLocalSSHKeys(keysDirectory string) ([]string, map[string]string, error)

func GetNKeyValuePairsStringMap added in v0.0.18

func GetNKeyValuePairsStringMap(kvd map[string]string) int

GetNKeyValuePairsStringMap returns the number of key-value mappings stored in the provided `kvd` (key-value dictionary)

func IsPathType added in v0.0.16

func IsPathType(pathInfo os.FileInfo, pathType PathType) bool

func PathExists added in v0.0.16

func PathExists(asType PathType, pathFragments ...string) (bool, error)

func ResolvePath added in v0.0.14

func ResolvePath(relativePathFragments ...string) (string, error)

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 PathType added in v0.0.16

type PathType string

func (PathType) String added in v0.0.16

func (pt PathType) String() string

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

Directories

Path Synopsis
Package request implements standardised ways of issuing outgoing calls to other servces.
Package request implements standardised ways of issuing outgoing calls to other servces.
Package system implements utility methods that should apply across all operating systems and can be called in a cross-platform compatible manner.
Package system implements utility methods that should apply across all operating systems and can be called in a cross-platform compatible manner.

Jump to

Keyboard shortcuts

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