helpers

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 18 Imported by: 0

README

helper

The package contains common helpers from Mr.X

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToContent added in v1.0.1

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

AppendToContent append string to a file

func ChunkFileByPart added in v1.0.1

func ChunkFileByPart(source string, chunk int) [][]string

ChunkFileByPart chunk file to multiple part

func ChunkFileBySize added in v1.0.1

func ChunkFileBySize(source string, chunk int) [][]string

ChunkFileBySize chunk file to multiple part

func CopyDir added in v1.0.1

func CopyDir(src string, dst string) error

CopyDir copy directory to dest

func CopyFile added in v1.0.1

func CopyFile(src, dst string) error

CopyFile copies a single file from src to dst

func DirLength added in v1.0.1

func DirLength(dir string) int

DirLength count len of file

func ExecutionWithStd

func ExecutionWithStd(cmd string) (string, error)

func ExpandLength added in v1.0.1

func ExpandLength(list []string, length int) []string

ExpandLength make slice to length

func FileExists added in v1.0.1

func FileExists(filename string) bool

FileExists check if file is exist or not

func FileLength added in v1.0.1

func FileLength(filename string) int

FileLength count len of file

func FolderExists added in v1.0.1

func FolderExists(foldername string) bool

FolderExists check if file is exist or not

func GenHash added in v1.0.1

func GenHash(text string) string

GenHash gen SHA1 hash from string

func GetCurrentDay added in v1.0.1

func GetCurrentDay() string

GetCurrentDay get current day

func GetCurrentTime

func GetCurrentTime() string

func GetDirFileInFolder

func GetDirFileInFolder(foldername string, filename string) []string

func GetFileContent added in v1.0.1

func GetFileContent(filename string) string

GetFileContent Reading file and return content of it

func GetFileNames added in v1.0.1

func GetFileNames(dir string, ext string) []string

GetFileNames get all file name with extension

func GetFileSize added in v1.0.1

func GetFileSize(src string) float64

GetFileSize get file size of a file in GB

func GetHomeFolder

func GetHomeFolder(foldername string) string

func GetLengthFile

func GetLengthFile(filename string) int

func GetOSEnv added in v1.0.1

func GetOSEnv(name string) string

GetOSEnv get enviroment variable

func GetTS added in v1.0.1

func GetTS() string

GetTS get current timestamp and return a string

func InputCmd

func InputCmd(Cmd string) string

func IsJSON added in v1.0.1

func IsJSON(str string) bool

IsJSON check if string is JSON or not

func JoinURL added in v1.0.1

func JoinURL(raw string, suffix string) string

func ListFileInFolder

func ListFileInFolder(foldername string) []string

func ListFilesWithPattern

func ListFilesWithPattern(foldername string, pattern string) []string

func LoadFile

func LoadFile(filename string) (lines []string)

func MakeDir added in v1.0.1

func MakeDir(folder string)

MakeDir just make a folder

func MoveFolder added in v1.0.1

func MoveFolder(src string, dest string)

MoveFolder move folder

func NormalizePath added in v1.0.1

func NormalizePath(path string) string

NormalizePath the path

func PromptConfirm added in v1.0.1

func PromptConfirm(s string) bool

func ReadingFileUnique added in v1.0.1

func ReadingFileUnique(filename string) []string

ReadingFileUnique Reading file and return content as []string

func ReadingLines added in v1.0.1

func ReadingLines(filename string) []string

ReadingLines Reading file and return content as []string

func RuncmdWithLabel

func RuncmdWithLabel(cmd string, label string) (string, error)

func SendWithDocument added in v1.0.4

func SendWithDocument(bot *tgbotapi.BotAPI, chatID int64, filepath string) error

func StartWithNum added in v1.0.1

func StartWithNum(raw string) bool

StartWithNum check if string start with number

func StrToInt added in v1.0.1

func StrToInt(data string) int

StrToInt string to int

func StripName added in v1.0.1

func StripName(raw string) string

StripName strip a file name

func WriteToFile added in v1.0.1

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

WriteToFile write string to a file

Types

This section is empty.

Jump to

Keyboard shortcuts

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