util

package
v0.0.0-...-e38a99a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpGet

func HttpGet(url string) (resp *http.Response, err error)

HttpGet get http resource

func HttpGetWithCookie

func HttpGetWithCookie(url string, cookies ...*http.Cookie) (resp *http.Response, err error)

HttpGetWithCookie get http resource with cookies

func HttpPost

func HttpPost(url string, data url.Values) (resp *http.Response, err error)

HttpPost send a post request with form data

func HttpPostFileWithCookie

func HttpPostFileWithCookie(url string, fieldName, fileName string, data url.Values, cookies ...*http.Cookie) (resp *http.Response, err error)

HttpPostFileWithCookie send a post request with form data, file and cookies

func HttpPostWithCookie

func HttpPostWithCookie(url string, data url.Values, cookies ...*http.Cookie) (resp *http.Response, err error)

HttpPostWithCookie send a post request with form data and cookies

func HttpPostWithoutRedirect

func HttpPostWithoutRedirect(url string, data url.Values) (resp *http.Response, err error)

HttpPostWithoutRedirect send a post request with form data and not auto redirect

func Int64

func Int64(v string) (int64, error)

Int64 parse the string to int64

func IsEmpty

func IsEmpty(s string) bool

IsEmpty is empty or whitespace string

func IsWindows

func IsWindows() bool

IsWindows is the Windows operating system

func MD5

func MD5(s string) (hash string)

MD5 calculate the hash value of the string

func MD5FromFile

func MD5FromFile(file io.Reader) (hash string, err error)

MD5FromFile calculate the hash value of the file If you reuse the file reader, please set its offset to start position first, like os.File.Seek

func MD5FromFileName

func MD5FromFileName(path string) (hash string, err error)

MD5FromFileName calculate the hash value of the file

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal returns the JSON encoding of v

func RandomString

func RandomString(length int) (s string)

RandomString generate a random string, max length is 20

func String

func String(v interface{}) string

String parse the v to string

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.

Types

type ToString

type ToString interface {
	// String return current format info
	String() string
}

Jump to

Keyboard shortcuts

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