utils

package
v0.0.0-...-815c261 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient *http.Client
View Source
var (
	UA string
)

Functions

func AppendToContent

func AppendToContent(filename string, data string) (string, error)

AppendToContent append string to a file

func BadBlockF

func BadBlockF(format string, args ...interface{})

BadBlockF print info message

func BannerF

func BannerF(format string, data string)

BannerF print info message

func Base64Encode

func Base64Encode(raw string) string

Base64Encode read image file as a string

func BlockF

func BlockF(name string, data string)

BlockF print info message

func CalcTimeout

func CalcTimeout(raw string) int

CalcTimeout calculate timeout

func Cat

func Cat(filename string)

Cat Reading file and return content as []string

func CleanPath

func CleanPath(raw string) string

CleanPath get environment variable

func Copy

func Copy(src string, dest string)

Copy append content to a file

func CountLines

func CountLines(filename string) int

CountLines Return the lines amount of the file

func Debug

func Debug(args ...interface{})

Debug print debug message

func DebugF

func DebugF(format string, args ...interface{})

DebugF print debug message

func DirLength

func DirLength(dir string) int

DirLength count len of file

func Emojif

func Emojif(e string, format string, args ...interface{}) string

Emojif print good message

func EmptyDir

func EmptyDir(dir string) bool

EmptyDir check if directory is empty or not

func EmptyFile

func EmptyFile(filename string, num int) bool

EmptyFile check if file is empty or not

func Error

func Error(args ...interface{})

Error print good message

func ErrorF

func ErrorF(format string, args ...interface{})

ErrorF print good message

func FileExists

func FileExists(filename string) bool

FileExists check if file is exist or not

func FileLength

func FileLength(filename string) int

FileLength count len of file

func FolderExists

func FolderExists(foldername string) bool

FolderExists check if file is exist or not

func FolderLength

func FolderLength(dir string) int

func GenHash

func GenHash(text string) string

GenHash gen SHA1 hash from string

func GetCurrentDay

func GetCurrentDay() string

GetCurrentDay get current day

func GetDomain

func GetDomain(raw string) (string, error)

GetDomain get domain from the URL

func GetFileContent

func GetFileContent(filename string) string

GetFileContent Reading file and return content of it

func GetFileSize

func GetFileSize(src string) float64

GetFileSize get file size of a file in GB

func GetOSEnv

func GetOSEnv(name string, defaultValue string) string

GetOSEnv get environment variable

func GetTS

func GetTS() string

GetTS get current timestamp and return a string

func GoodF

func GoodF(format string, args ...interface{})

GoodF print good message

func ImageAsBase64

func ImageAsBase64(src string) string

ImageAsBase64 read image file as a string

func Infor

func Infor(args ...interface{})

Infor print info message

func InforF

func InforF(format string, args ...interface{})

InforF print info message

func InitHTTPClient

func InitHTTPClient()

func InitLog

func InitLog(options *libs.Options)

InitLog init log

func IsFile

func IsFile(src string) bool

func IsWritable

func IsWritable(filename string) (isWritable bool, err error)

func MakeDir

func MakeDir(folder string)

MakeDir just make a folder

func Move

func Move(src string, dest string) error

func NormalizePath

func NormalizePath(path string) string

NormalizePath the path

func PrefixF

func PrefixF(symbol string, format string, args ...interface{})

PrefixF print good message

func PrintLine

func PrintLine()

PrintLine print seperate line

func RandomString

func RandomString(n int) string

RandomString return a random string with length

func ReadingFileUnique

func ReadingFileUnique(filename string) []string

ReadingFileUnique Reading file and return content as []string

func ReadingLines

func ReadingLines(filename string) []string

ReadingLines Reading file and return content as []string

func RenderText

func RenderText(format string, data map[string]string) string

RenderText resolve template from signature file

func RunCmdWithOutput

func RunCmdWithOutput(command string, timeoutRaw ...string) string

RunCmdWithOutput run command with timeout

func RunCommandSteamOutput

func RunCommandSteamOutput(cmd string) (string, error)

func RunCommandWithErr

func RunCommandWithErr(command string, timeoutRaw ...string) (string, error)

RunCommandWithErr Run a command

func RunCommandWithoutOutput

func RunCommandWithoutOutput(cmd string) error

RunCommandWithoutOutput Run a command

func RunOSCommand

func RunOSCommand(cmd string) (string, error)

func RunOSCommandStream

func RunOSCommandStream(cmd, std string) error

func StrToInt

func StrToInt(data string) int

StrToInt string to int

func StripPath

func StripPath(raw string) string

StripPath just Base64 Encode

func TSPrintF

func TSPrintF(format string, args ...interface{})

TSPrintF print info message

func Trace

func Trace(args ...interface{})

Trace print good message

func TraceF

func TraceF(format string, args ...interface{})

TraceF print good message

func Warn

func Warn(args ...interface{})

Warn print good message

func WarnF

func WarnF(format string, args ...interface{})

WarnF print good message

func WriteToFile

func WriteToFile(filename string, data string) (string, error)

WriteToFile write string to a file

func ZippedFolder

func ZippedFolder(src string, dest string) error

ZippedFolder zip a folder

Types

type OffsetRange

type OffsetRange struct {
	File  string
	Start int64
	Stop  int64
}

OffsetRange represents a content block of a file.

func SplitLineChunks

func SplitLineChunks(filename string, chunks int) ([]OffsetRange, error)

SplitLineChunks splits file into chunks. The whole line are guaranteed to be split in the same chunk.

type RangeReader

type RangeReader struct {
	// contains filtered or unexported fields
}

A RangeReader is used to read a range of content from a file.

func NewRangeReader

func NewRangeReader(file *os.File, start, stop int64) *RangeReader

NewRangeReader returns a RangeReader, which will read the range of content from file.

func (*RangeReader) Read

func (rr *RangeReader) Read(p []byte) (n int, err error)

Read reads the range of content into p.

type Response

type Response struct {
	StatusCode int
	Status     string
	Body       string
}

func SendGET

func SendGET(cred string, url string) (res Response)

SendGET sending GET request

func SendPOST

func SendPOST(cred string, url string, body string) (res Response)

SendPOST sending POST request

func SendPUT

func SendPUT(cred string, url string, body string) (res Response)

SendPUT sending POST request

Jump to

Keyboard shortcuts

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