pcsutil

package
v3.5.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package pcsutil 工具包

Index

Constants

This section is empty.

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 (
	// ErrorColor 设置输出错误的颜色
	ErrorColor = color.New(color.FgRed).SprintFunc()
)
View Source
var (
	// PipeInput 命令中是否为管道输入
	PipeInput bool
)

Functions

func ChWorkDir

func ChWorkDir()

ChWorkDir 切换回工作目录

func ContainsString

func ContainsString(ss []string, s string) bool

ContainsString 检测字符串是否在字符串数组里

func ConvertToUnixPathSeparator

func ConvertToUnixPathSeparator(p string) string

ConvertToUnixPathSeparator 将 windows 目录分隔符转换为 Unix 的

func CryptoMethodSupport

func CryptoMethodSupport(method string) bool

CryptoMethodSupport 检测是否支持加密解密方法

func DecompressGZIP

func DecompressGZIP(r io.Reader) ([]byte, error)

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 Executable

func Executable() string

Executable 获取程序所在的真实目录或真实相对路径

func ExecutablePath

func ExecutablePath() string

ExecutablePath 获取程序所在目录

func ExecutablePathJoin

func ExecutablePathJoin(subPath string) string

ExecutablePathJoin 返回程序所在目录的子目录

func FlagProvided

func FlagProvided(names ...string) bool

FlagProvided 检测命令行是否提供名为 name 的 flag, 支持多个name(names)

func GetURLCookieString

func GetURLCookieString(urlString string, jar *cookiejar.Jar) string

GetURLCookieString 返回cookie字串

func IsIPhoneOS

func IsIPhoneOS() bool

IsIPhoneOS 是否为苹果移动设备

func ListAddresses

func ListAddresses() (addresses []string)

ListAddresses 列出本地可用的 IP 地址

func PrintErrAndExit

func PrintErrAndExit(annotate string, err error)

PrintErrAndExit 简易错误处理, 如果 err 存在, 向屏幕输出 err 并退出, annotate 是加在 err 之前的注释信息。

func PrintErrIfExist

func PrintErrIfExist(err error)

PrintErrIfExist 简易错误处理, 如果 err 存在, 就只向屏幕输出 err 。

func SetLogPrefix

func SetLogPrefix()

SetLogPrefix 设置日志输出的时间前缀

func Trigger

func Trigger(f func())

Trigger 用于触发事件

func TriggerOnSync

func TriggerOnSync(f func())

TriggerOnSync 用于触发事件, 同步触发

func WalkDir

func WalkDir(dirPth, suffix string) (files []string, err error)

WalkDir 获取指定目录及所有子目录下的所有文件,可以匹配后缀过滤。

Types

This section is empty.

Directories

Path Synopsis
Package checksum 校验本地文件包
Package checksum 校验本地文件包
Package converter 格式, 类型转换包
Package converter 格式, 类型转换包
Package getip 获取 ip 信息包
Package getip 获取 ip 信息包
Package pcstime 时间工具包
Package pcstime 时间工具包
Package waitgroup sync.WaitGroup extension
Package waitgroup sync.WaitGroup extension

Jump to

Keyboard shortcuts

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