util

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnterPassword  = "Enter Password"
	RepeatPassword = "Repeat Password"
)

Variables

View Source
var (
	ErrPasswordInconsistent = errors.New("passwords are inconsistent")
)
View Source
var (
	ErrSignInFailed = errors.New("sign in failed")
)

Functions

func ConfirmPassword added in v0.7.0

func ConfirmPassword() (string, error)

func ConvertStringToMap added in v0.7.0

func ConvertStringToMap(key string) map[string]string

ConvertStringToMap 将 'key1=value1;key2=value2' 转换成 map

func Decrypt

func Decrypt(key, ciphertext []byte) []byte

func DeleteJson added in v0.5.0

func DeleteJson(url string, req, rsp interface{}) error

func Encrypt

func Encrypt(key, text []byte) (d []byte)

func GetJson added in v0.6.0

func GetJson(url string, header map[string]string, rsp interface{}) error

func GetPassword added in v0.5.1

func GetPassword() (string, error)

func Hold

func Hold()

func NewJar added in v0.7.0

func NewJar(key, domain, u string) *cookiejar.Jar

NewJar 从给定 cookie 字符串构造 jar

func NewRequest added in v0.7.0

func NewRequest(method, url string, body io.Reader) (*http.Request, context.CancelFunc, error)

func NewTLSConfig added in v0.7.0

func NewTLSConfig(ca, cert, key string) *tls.Config

func ParseBody added in v0.7.0

func ParseBody(client *http.Client, u string, v interface{}) error

ParseBody 解析 body 中的 json 数据到 v

func ParseBodyHeader added in v0.7.0

func ParseBodyHeader(client *http.Client, u string, header map[string]string) error

ParseBodyHeader 用于访问一个 url, 并且可以指定 http.Request header

func ParseBodyPost added in v0.7.0

func ParseBodyPost(client *http.Client, u string, reader io.Reader, v interface{}) error

ParseBodyPost 可以指定 http.Request body

func ParseRawBody added in v0.7.0

func ParseRawBody(client *http.Client, u string) ([]byte, error)

ParseRawBody 读取 body 为 []byte

func PopulateStruct added in v0.7.0

func PopulateStruct(key string, s interface{}) error

PopulateStruct 从 key 中解码数据到 s

func PostForm added in v0.7.0

func PostForm(url string, f url.Values) (*http.Client, *http.Response, error)

PostForm 使用带 context 方式发送请求, 并返回 client 和 response. 返回 client 的意图是其中保存了 cookie, 以便后续发送请求可重用该 cookie.

func PostJson added in v0.4.2

func PostJson(url string, req, rsp interface{}) error

func PutJson added in v0.5.0

func PutJson(url string, req, rsp interface{}) error

func ReadPassword added in v0.5.1

func ReadPassword(prompt string) (string, error)

func ResolveCookies added in v0.7.0

func ResolveCookies(raw, domain string) []*http.Cookie

ResolveCookies 从字符构造 http.Cookie

func Salt

func Salt() string

func VerifyDate added in v0.7.0

func VerifyDate(raw string) error

VerifyDate 验证指定时间字符串与当前时间的日期是否相同

func WithSalt

func WithSalt(pass, salt string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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