common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

  • Package common @Author: zhizhuo @IDE:GoLand @File: common.go @Date: 2025/2/20 下午3:37*
  • Package common @Author: zhizhuo @IDE:GoLand @File: file.go @Date: 2025/2/20 下午3:37*
  • Package common @Author: zhizhuo @IDE:GoLand @File: yaml.go @Date: 2025/4/2 下午2:02*

Index

Constants

View Source
const (
	HttpType = "http"
	TcpType  = "tcp"
	UdpType  = "udp"
	SslType  = "ssl"
	GoType   = "go"
)

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(braw []byte) []byte

Base64Encode base64 encode

func DealMultipart

func DealMultipart(contentType string, ruleBody string) (result string, err error)

DealMultipart 处理multipart的/n问题

func Exists

func Exists(path string) bool

Exists 判断文件是否存在

func FromHex

func FromHex(data string) string

FromHex 将十六进制字符串转换为普通字符串

func GetRandomIP

func GetRandomIP() string

GetRandomIP 获取随机ip地址

func IsYamlFile

func IsYamlFile(filename string) bool

IsYamlFile 判断文件是否为YAML格式

func Mmh3Hash32

func Mmh3Hash32(raw []byte) int32

Mmh3Hash32 计算 mmh3 hash

func ParseTarget

func ParseTarget(target, path string) string

ParseTarget 处理请求url地址

func ParseUrl

func ParseUrl(u *url.URL) *proto.UrlType

func RandFromChoices

func RandFromChoices(n int, choices string) string

RandFromChoices 从choices里面随机获取

func RandLetters

func RandLetters(n int) string

RandLetters 随机小写字母

func RandomString

func RandomString(len int) string

RandomString 生成随机字符串

func RandomUA

func RandomUA() string

RandomUA 返回一个高度真实的随机 User-Agent 保证平台-浏览器-版本号的搭配逻辑正确(如 Safari 只出现在 Apple 平台)

func RemoveDuplicateURLs

func RemoveDuplicateURLs(urls []string) []string

RemoveDuplicateURLs 去除重复的URL

func RemoveTrailingSlash

func RemoveTrailingSlash(url string) string

RemoveTrailingSlash 删除URL中的最后一个/

func ReverseString

func ReverseString(s string) string

func Str2UTF8

func Str2UTF8(str string) string

Str2UTF8 字符串转 utf 8

func Url2UrlType

func Url2UrlType(u *url.URL) *proto.UrlType

func UrlTypeToString

func UrlTypeToString(u *proto.UrlType) string

Types

type AddressInfo

type AddressInfo struct {
	Host     string
	Port     string
	Scheme   string
	Hostname string
	IsLts    bool
}

AddressInfo 封装解析结果的结构体

func ParseAddress

func ParseAddress(address string) (AddressInfo, error)

ParseAddress 解析地址并返回 AddressInfo

Jump to

Keyboard shortcuts

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