ptools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertString

func ConvertString(s string) string

转换编码解决乱码问题 字符串

func DownloadFile

func DownloadFile(url string, location string) error

下载文件 (下载地址,存放位置)

func Exec

func Exec(command string) (output string, err error)

执行一次command指令 跨平台兼容

func ExecRealtime

func ExecRealtime(command string, method func(line string)) error

执行一次command指令且自定义方法处理每行结果 跨平台兼容

func ExecRealtimePause

func ExecRealtimePause(command string, method func(line string))

TODO 暂时只能linux macos使用 windows要用pstools.exe

func ExecRealtimePrint

func ExecRealtimePrint(command string) error

执行一次command指令且实时输出每行结果 跨平台兼容

func ExecRealtimePrintGBK

func ExecRealtimePrintGBK(command string) error

func FormatAbsPath

func FormatAbsPath(s string) string

规格化到绝对路径

func FormatPath

func FormatPath(s string) string

规格化路径 \ -> /

func GetBinaryPath

func GetBinaryPath(binary string) (string, error)

查找(环境变量+当前位置)可执行文件的位置 跨平台兼容

func GetHttpData

func GetHttpData(url string) (string, error)

利用HTTP Get请求获得数据

func Getwd

func Getwd() (wd string)

获取当前程序路径 最好直接用 os.Getwd

func IsFileExisted

func IsFileExisted(path string) bool

判断文件/文件夹是否存在

func IsNonASCII

func IsNonASCII(str string) bool

判断是不是non-ASCII

func ListDir

func ListDir(path2List, suffix string) (files []string, err error)

获取指定路径下的所有文件,只搜索当前路径,不进入下一级目录,可匹配后缀过滤(suffix为空则不过滤)TODO

func ReadAll

func ReadAll(path string) (string, error)

快速打开文件和读内容

func ScanCRorLF

func ScanCRorLF(data []byte, atEOF bool) (advance int, token []byte, err error)

自定义Scanner分割的方式,\n和\r都分割

func Test

func Test()

简单测试 打个招呼

func WriteFast

func WriteFast(filePath string, content string) error

快速文件写先清空再写入

func XCopy

func XCopy(from, to string) error

复制文件夹或者文件

func XMove

func XMove(from, to string) error

移动文件夹或者文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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