utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(url string, opts ...RequestOption) ([]byte, error)

Get 发送 HTTP GET 请求

func MD5

func MD5(str string) string

MD5 计算字符串哈希

func Post

func Post(url string, body io.Reader, opts ...RequestOption) ([]byte, error)

Post 发送 HTTP POST 请求 body 这里的类型是 io.Reader,可以传 strings.NewReader(form.Encode())

func RandomChinaIP

func RandomChinaIP() string

RandomChinaIP 生成一个随机的中国大陆 IP 地址

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename 移除文件名中的非法字符

Types

type RequestOption

type RequestOption func(*http.Request)

RequestOption 定义请求选项函数

func WithHeader

func WithHeader(key, value string) RequestOption

WithHeader 添加自定义 Header

func WithRandomIPHeader

func WithRandomIPHeader() RequestOption

WithRandomIPHeader 为请求添加随机的国内 IP Header

Jump to

Keyboard shortcuts

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