Documentation ¶
Overview ¶
Package pcsutil 工具包
Index ¶
- Constants
- Variables
- func BeijingTimeOption(get string) string
- func ConvertFileSize(size int64, precision ...int) string
- func ConvertToUnixPathSeparator(p string) string
- func CryptoMethodSupport(method string) bool
- func DecompressGZIP(r io.Reader) ([]byte, error)
- func DecryptFile(method string, key []byte, filePath string, isGzip bool) (decryptedFilePath string, err error)
- func EncryptFile(method string, key []byte, filePath string, isGzip bool) (encryptedFilePath string, err error)
- func ExecutablePath() string
- func ExecutablePathJoin(subPath string) string
- func FlagProvided(names ...string) bool
- func FormatTime(t int64) string
- func GetURLCookieString(urlString string, jar *cookiejar.Jar) string
- func IntToBool(i int) bool
- func ListAddresses() (addresses []string)
- func PrintErrAndExit(annotate string, err error)
- func PrintErrIfExist(err error)
- func SetLogPrefix()
- func ShortDisplay(s string, num int) string
- func ToBytes(str string) []byte
- func ToString(p []byte) string
- func WalkDir(dirPth, suffix string) (files []string, err error)
- type WaitGroup
Constants ¶
View Source
const ( // B byte B = (int64)(1 << (10 * iota)) // KB kilobyte KB // MB megabyte MB // GB gigabyte GB // TB terabyte TB // PB petabyte PB )
Variables ¶
View Source
var ( // HTTPSRE https regexp HTTPSRE = regexp.MustCompile("^https") // ChinaPhoneRE https regexp ChinaPhoneRE = regexp.MustCompile(`^(\+86)?1[3-9][0-9]\d{8}$`) )
View Source
var ( // CSTLocation 东八区时区 CSTLocation = time.FixedZone("CST", 8*3600) )
View Source
var ( // ErrorColor 设置输出错误的颜色 ErrorColor = color.New(color.FgRed).SprintFunc() )
View Source
var ( // PipeInput 命令中是否为管道输入 PipeInput bool )
Functions ¶
func BeijingTimeOption ¶
BeijingTimeOption 根据给定的 get 返回时间格式.
get: 时间格式 "Refer": 2017-7-21 12:02:32.000 "printLog": 2017-7-21_12:02:32 "day": 21 "ymd": 2017-7-21 "hour": 12 默认时间戳: 1500609752
func ConvertFileSize ¶
ConvertFileSize 文件大小格式化输出
func ConvertToUnixPathSeparator ¶
ConvertToUnixPathSeparator 将 windows 目录分隔符转换为 Unix 的
func CryptoMethodSupport ¶
CryptoMethodSupport 检测是否支持加密解密方法
func DecompressGZIP ¶
DecompressGZIP 对 io.Reader 数据, 进行 gzip 解压
func DecryptFile ¶
func DecryptFile(method string, key []byte, filePath string, isGzip bool) (decryptedFilePath string, err error)
DecryptFile 加密本地文件
func EncryptFile ¶
func EncryptFile(method string, key []byte, filePath string, isGzip bool) (encryptedFilePath string, err error)
EncryptFile 加密本地文件
func ExecutablePathJoin ¶
ExecutablePathJoin 返回程序所在目录的子目录
func FlagProvided ¶
FlagProvided 检测命令行是否提供名为 name 的 flag, 支持多个name(names)
func GetURLCookieString ¶
GetURLCookieString 返回cookie字串
func PrintErrAndExit ¶
PrintErrAndExit 简易错误处理, 如果 err 存在, 向屏幕输出 err 并退出, annotate 是加在 err 之前的注释信息。
func PrintErrIfExist ¶
func PrintErrIfExist(err error)
PrintErrIfExist 简易错误处理, 如果 err 存在, 就只向屏幕输出 err 。
func ShortDisplay ¶
ShortDisplay 缩略显示字符串s, 显示长度为num, 缩略的内容用"..."填充
Types ¶
Click to show internal directories.
Click to hide internal directories.