util

package module
v0.0.0-...-0aecb2a Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT Imports: 13 Imported by: 0

README

util

go语言开发中常用的工具包,例如http的请求,下载文件,上传文件等

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIntValueJson

func BuildIntValueJson(kvs map[string]int) string

func BuildJson

func BuildJson(kvs map[string]string) string

func CheckFileSize

func CheckFileSize(file *os.File, limit int64) bool

func CheckFileType

func CheckFileType(filePath string, exts ...string) bool

func DownLoadFileByGet

func DownLoadFileByGet(url, savePath string) (string, error)

支持重定向文件下载

func DownloadFileByPostFields

func DownloadFileByPostFields(url, savePath string, fields map[string]string) (string, error)

用于需要上传form表单下载文件的情况

func DownloadFileByPostRawData

func DownloadFileByPostRawData(url, savePath string, rawData []byte) (string, error)

用于需要上传json串等数据下载文件的情况

func Get

func Get(url string) ([]byte, error)

func GetRandomStr

func GetRandomStr(len int) string

func InArray

func InArray(val interface{}, array interface{}) bool

该方法支持所有类型的判断,但是严重影响性能

func PostFields

func PostFields(url string, fields map[string]string) ([]byte, error)

func PostFiles

func PostFiles(url string, files map[string]string) ([]byte, error)

支持多文件上传

func PostFilesAndFields

func PostFilesAndFields(url string, files map[string]string, fields map[string]string) ([]byte, error)

支持多文件上传

func PostRawData

func PostRawData(url string, data []byte) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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