utils

package
v0.0.0-...-55d16bb Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTrailingSlashToPath

func AddTrailingSlashToPath(path string) string

func CopyDir

func CopyDir(source string, dest string) (err error)

Recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.

func CopyFile

func CopyFile(source string, dest string) (err error)

Copies file source to destination dest.

func CopyFileIfNotExists

func CopyFileIfNotExists(source string, dest string) (err error)

func Debounce

func Debounce(delay time.Duration, f func()) func()

Debounce executes a function when it stops being invoked for the delay.

func DecryptXorBase64

func DecryptXorBase64(key string, s string) (string, error)

DecryptXorBase64 is a simple XOR decryption

func EncryptDomId

func EncryptDomId(key string, s string) (hash string)

EncryptDomId calculates a short unique DOM ID hash

func EncryptXorBase64

func EncryptXorBase64(key string, s string) string

EncryptXorBase64 is a simple XOR encryption

func ErrorBox

func ErrorBox(err string, vars ...interface{}) template.HTML

ErrorBox returns a styled div error box. One optional argument can be passed to show a detailed error code. This error code is only shown to the user if the sessions is authenticated as developer.

func EscapeJS

func EscapeJS(data string) string

EscapeJS escapes a string to be send over the SendCommand method. This method escapes all backslaches, simple quotes and new lines.

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given file or directory exists or not

func Fields

func Fields(s string) ([]string, error)

Fields splits a string between spaces, but skips spaces in quotes. nil is returned, if the string is empty or if it only contains empty spaces.

func IsDir

func IsDir(path string) (bool, error)

func LimitLen

func LimitLen(s string, max int) string

LimitLen will cut a string if it exceeds the max length.

func MkDirIfNotExists

func MkDirIfNotExists(path string) error

MkDirIfNotExists creates a directory if it doesn't exists

func RandomString

func RandomString(n int) string

RandomString generates a random string with a length of n

func RemoteAddress

func RemoteAddress(r *http.Request) (string, bool)

RemoteAddress returns the IP address of the request. If the X-Forwarded-For or X-Real-Ip http headers are set, then they are used to obtain the remote address. The boolean is true, if the remote address is obtained using the request RemoteAddr() method.

func RemovePortFromRemoteAddr

func RemovePortFromRemoteAddr(remoteAddr string) string

RemovePortFromRemoteAddr removes the port if present from the remote address.

func Sha256Sum

func Sha256Sum(s string) string

func ToPath

func ToPath(path string) string

ToPath returns a valid path.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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