utils

package
v0.6.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxCopy added in v0.5.0

func CtxCopy(ctx context.Context, dst io.Writer, src io.Reader) (written int64, err error)

func CtxCopyN added in v0.5.0

func CtxCopyN(ctx context.Context, dst io.Writer, src io.Reader, n int64) (written int64, err error)

func EnsureFolder

func EnsureFolder(path string) error

EnsureFolder creates a folder if it doesn't exist already

func IsIgnoredFile added in v0.2.1

func IsIgnoredFile(file string) bool

IsIgnoredFile returns true if the file should be ignored and not added to the repository Ignored files include OS metadata files etc

func IsRegularFile

func IsRegularFile(path string) (bool, error)

IsRegularFile returns true if the path is a file

func IsTruthy

func IsTruthy(str string) bool

IsTruthy returns true if a string represent a "true" value, such as "true", "1", etc

func Mapify

func Mapify(m interface{}) map[string]interface{}

Mapify converts a struct to a map[string]interface{} If fields are structs, they're converted to their textual representation

func PathExists

func PathExists(path string) (bool, error)

PathExists returns true if the path exists on disk

func SanitizeConnectionName

func SanitizeConnectionName(conn string) string

SanitizeConnectionName returns a sanitized name for a connection or an empty string

func SanitizeMimeType added in v0.3.0

func SanitizeMimeType(mime string) string

SanitizeMimeType sanitizes a mime type

func SanitizePath added in v0.2.0

func SanitizePath(path string) string

SanitizePath removes certain problematic characters from path names

func StringInSlice

func StringInSlice(list []string, a string) bool

StringInSlice checks if a string is contained inside a slice of strings

func TouchFile

func TouchFile(name string) (err error)

TouchFile creates an empty file if it doesn't exist

Types

type CtxReader added in v0.5.0

type CtxReader func(p []byte) (n int, err error)

func ReaderFuncWithContext added in v0.4.1

func ReaderFuncWithContext(ctx context.Context, r io.Reader) CtxReader

ReaderFuncWithContext returns a stream reader that supports a context

func (CtxReader) Read added in v0.5.0

func (rf CtxReader) Read(p []byte) (n int, err error)

type CtxWriter added in v0.5.0

type CtxWriter func(p []byte) (n int, err error)

func (CtxWriter) Write added in v0.5.0

func (rf CtxWriter) Write(p []byte) (n int, err error)

type HttpRange added in v0.5.0

type HttpRange struct {
	Start, Length int64
}

HttpRange specifies the byte range to be sent to the client.

func ParseRange added in v0.5.0

func ParseRange(s string) (*HttpRange, error)

ParseRange parses a Range header string as per a subset of RFC 7233 This supports two formats only: `bytes=startByte-` and `bytes=startByte-endByte` (that's the least common denominator supported by all services)

Jump to

Keyboard shortcuts

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