tool

package
v1.2.19 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAndChange

func CopyAndChange(source interface{}, target interface{}) map[string]interface{}

func CreateFile

func CreateFile(FilePath, FileName string) *os.File

func DeepCopyMap added in v1.2.4

func DeepCopyMap(source interface{}) (target interface{})

map的深度复制

只支持值类型为:

Array,Slice,元数据类型,不支持struct,map

func DownloadInternetImage

func DownloadInternetImage(url string, UserAgent string, Referer string) string

func DownloadInternetImageTemp

func DownloadInternetImageTemp(url string, UserAgent string, Referer string) string

func FindChange

func FindChange(source interface{}, target interface{}) map[string]interface{}

func GetAllFieldName

func GetAllFieldName(t reflect.Type) []string

func GetDeviceName

func GetDeviceName(UserAgent string) string

Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1 Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36 Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1

func GetHardwareAddrs

func GetHardwareAddrs() string

func GetIP

func GetIP(request *http.Request) string

func IsFileExist

func IsFileExist(path string) bool

func QueryParams

func QueryParams(m url.Values) map[string]string

func RequestByHeader

func RequestByHeader(url string, UserAgent string, Referer string) (error, *http.Response, []byte)

func RequestByHeader(url string, UserAgent string, Referer string) ([]byte,error) {

client := http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
	return nil,err
}
//req.Header.Add("User-Agent","Mozilla/5.0 (Linux; Android 7.0; SLA-AL00 Build/HUAWEISLA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/044109 Mobile Safari/537.36 MicroMessenger/6.6.7.1321(0x26060739) NetType/WIFI Language/zh_CN")
if !strings.EqualFold(UserAgent, "") {
	req.Header.Add("User-Agent", UserAgent)
}

if !strings.EqualFold(Referer, "") {
	req.Header.Add("Referer", Referer)
}

resp, err := client.Do(req)
if err != nil {
	return nil,err
}
defer resp.Body.Close()

b, err := ioutil.ReadAll(resp.Body)

return b,err

}

func UUID

func UUID() string

func WriteFile

func WriteFile(b []byte, ContentType string) string

func WriteFilePath added in v1.2.4

func WriteFilePath(read []byte, subPath string, fileName string) (error, string)

func WriteTempFile

func WriteTempFile(b []byte, ContentType string) string

func WriteTempUrlNameFile

func WriteTempUrlNameFile(b []byte, Url string) string

func WriteWithFile added in v1.2.11

func WriteWithFile(file multipart.File, header *multipart.FileHeader, dynamicDirName string) (error, string)

Types

type FileDirType

type FileDirType int32
var FileDirT FileDirType = 1
var FileDirTemp FileDirType = 1

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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