util

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenAllMatchDomain

func GenAllMatchDomain(name string) []string

GenAllMatchDomain 生成能够与目标域名匹配的所有解析域名的翻转格式 如 "a.b.example.com" -> ["com.example.b.a", "com.example.b.a.*", "com.example.b.*", "com.example.*"]

func ReverseDomain

func ReverseDomain(str string) string

ReverseDomain 翻转域名 如'a.example.com' -> 'com.example.a'

func ReverseDomainAndToSlice

func ReverseDomainAndToSlice(str string) []string

ReverseDomainAndToSlice 翻转域名并解析为切片 目前已知多后缀域名只有一个"com.cn",所以处理该类型的域名时会将"com.cn"看为一个整体 如'a.example.com' -> ["com", "example", "a"] 如'a.example.com.cn' -> ["com.cn", "example", "a"]

func SliceDeduplication

func SliceDeduplication[T comparable](ts []T) []T

SliceDeduplication 对切片元素进行去重,但是需要确保切片是可比较的

func SliceRandom

func SliceRandom[T any](p []T) []T

SliceRandom 返回经过乱序后的 p

func SliceRemoveItem

func SliceRemoveItem[T any](s []T, i int) []T

SliceRemoveItem 删除切片中指定位置的元素,相比于常用的 `s = append(s[:i], s[i+1:]...)` 具有更高的效率

Types

This section is empty.

Jump to

Keyboard shortcuts

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