Documentation ¶
Index ¶
- Constants
- Variables
- func AnonymizeIp(ip []byte) []byte
- func CopyBytes(input []byte) []byte
- func CreateDirectory(path string, perm fs.FileMode) (string, error)
- func CreateDirectoryFromFile(path string, perm fs.FileMode) (string, error)
- func CreateFile(path string, flags int, dirMode, mode fs.FileMode) (file *os.File, err error)
- func CreateLogFile(path string) (file *os.File, err error)
- func DecodeQuery(dst []byte, src []byte) (int, error)
- func DecodeQueryUnsafe(src []byte) ([]byte, error)
- func DecodeQueryUnsafeString(src []byte) (string, error)
- func FileExists(path string) bool
- func GetAbsolutePath(path string) (string, error)
- func GetBrokenImageBytes() []byte
- func GetLocalIP() string
- func GetLocalIPs() []string
- func GetRequestId() (string, error)
- func Getenv(env string, def ...string) string
- func IsHex(c byte) bool
- func IsInt(s string) bool
- func IsSuccess(status int) bool
- func RandomString(n int32) string
- func RealIp(peekable Peekable) []byte
- func TruncateUrl(value []byte) []byte
- func UnHex(c byte) byte
- func UnsafeBytes(s string) []byte
- func UnsafeString(b []byte) string
- type Peekable
Constants ¶
const ( UnknownIp = "UNKNOWN IP" HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-IP" )
const ( // RequestIdLength RequestIdLength = 32 // MaxEncodedLength MaxEncodedLength = (RequestIdLength*8 + 5) / 6 )
Variables ¶
var ( GooglePlay = []byte("play.google") ITunesApple = []byte("itunes.apple") HTTPS = []byte("https://") HTTP = []byte("http://") HTTPSProtocol = []byte("https:") HTTPProtocol = []byte("http:") )
var ErrEscape = errors.New("invalid URL escape")
Functions ¶
func AnonymizeIp ¶
Slices IP address byte slice and writes 0 to last octet Example: AnonymizeIp([]byte{'1','9','2','.','1','7','2','.','9','0','.','7','0'}) Returns []byte{'1','9','2','.','1','7','2','.','9','0','.','0'}
func CreateDirectory ¶
Provides a way of creating directory with permissions for a given path Returns string path of created directory and error if fails
func CreateDirectoryFromFile ¶
Provides a way of creating a directory from a path Returns created directory path and error if fails
func CreateFile ¶
Creates file for given directory with flags and permissions for directory and file Returns file instance and error if it fails
func CreateLogFile ¶
Creates write only appendable file with permission 0o744 for directory and file for given path
func DecodeQueryUnsafe ¶ added in v0.9.1
func DecodeQueryUnsafeString ¶ added in v0.9.1
func FileExists ¶
Provides a way of checking if file exists. Returns bool
func GetAbsolutePath ¶
Returns absolute path string for a given directory and error if directory doesent exist
func GetBrokenImageBytes ¶ added in v0.9.1
func GetBrokenImageBytes() []byte
func GetLocalIP ¶
func GetLocalIP() string
Returns IP address of local machine, empty string if fails
func IsInt ¶
Provides a way of testing if type is integer Returns bool value depending if its integer or not
func RealIp ¶ added in v0.13.3
Extracts first ip address from Peekable interface seperated by coma Returns nil if no values are presemt
func UnsafeBytes ¶
#nosec G103 Returns a byte pointer without allocation
func UnsafeString ¶
#nosec G103 Returns a string pointer without allocation