tools

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2021 License: Apache-2.0 Imports: 18 Imported by: 44

README

tools

go的工具集

安装

go get github.com/PeterYangs/tools

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToByte added in v0.1.2

func ConvertToByte(src string, srcCode string, targetCode string) []byte

func Date added in v0.0.6

func Date(format string, timestamp int64) string

先用比较蠢的办法

func DeleteFile

func DeleteFile(path string) error

删除文件

func DownloadFile

func DownloadFile(url string, path string, setting HttpSetting) error

下载文件

func DownloadImage added in v0.0.3

func DownloadImage(url string, path string, setting HttpSetting) error

图片下载

func Explode added in v0.0.4

func Explode(delimiter, text string) []string

func GetExtensionName added in v0.0.11

func GetExtensionName(fileName string) (string, error)

获取文件名拓展名

func GetToBody added in v0.1.1

func GetToBody(url string, setting HttpSetting) (io.ReadCloser, error)

注意要手动关闭body

func GetToResp added in v0.1.1

func GetToResp(url string, setting HttpSetting) (*http.Response, error)

注意要手动关闭body

func GetToString added in v0.1.0

func GetToString(url string, setting HttpSetting) (string, error)

get获取字符串结果

func Implode added in v0.2.4

func Implode(glue string, pieces []string) string

func In_array added in v0.0.8

func In_array(array interface{}, item interface{}) bool

func IsGBK added in v0.1.2

func IsGBK(data []byte) bool

func Join added in v0.2.4

func Join(glue string, pieces []string) string

func Md5 added in v0.0.4

func Md5(str string) string

func MkDirDepth added in v0.0.12

func MkDirDepth(path string) error

创建多级文件夹

func Mt_rand added in v0.0.13

func Mt_rand(min, max int64) int64

生成固定区间的随机数

func PostToString added in v0.1.0

func PostToString(url string, setting HttpSetting) (string, error)

post获取字符串结果

func Query

func Query(url string, method string, setting HttpSetting) (*http.Response, error)

请求底层函数

func ReadFile

func ReadFile(path string) (string, error)

读取文件

func SendEmail added in v0.0.5

func SendEmail(from string, to []string, title string, content string, host string, port int, password string) error

发送邮件

func StrToTime added in v0.0.6

func StrToTime(str string) int64

func WriteLine

func WriteLine(path string, data string)

Types

type HttpSetting added in v0.1.0

type HttpSetting struct {
	TimeOut      int                    //超时时间
	Header       map[string]string      //header
	Parameter    map[string]interface{} //参数
	ProxyAddress string                 //代理地址
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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