configutils

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: BSD-3-Clause Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCharsets = []maps.Map{}/* 122 elements not displayed */
View Source
var BasicCharsets = []maps.Map{
	{"name": "Chinese Traditional (Big5)", "charset": "big5"},
	{"charset": "euc-kr", "name": "Korean (EUC)"},
	{"charset": "iso-8859-1", "name": "Western Alphabet"},
	{"charset": "iso-8859-2", "name": "Central European Alphabet (ISO)"},
	{"charset": "iso-8859-3", "name": "Latin 3 Alphabet (ISO)"},
	{"charset": "iso-8859-4", "name": "Baltic Alphabet (ISO)"},
	{"charset": "iso-8859-5", "name": "Cyrillic Alphabet (ISO)"},
	{"charset": "iso-8859-6", "name": "Arabic Alphabet (ISO)"},
	{"charset": "iso-8859-7", "name": "Greek Alphabet (ISO)"},
	{"charset": "iso-8859-8", "name": "Hebrew Alphabet (ISO)"},
	{"charset": "koi8-r", "name": "Cyrillic Alphabet (KOI8-R)"},
	{"charset": "shift-jis", "name": "Japanese (Shift-JIS)"},
	{"name": "Japanese (EUC)", "charset": "x-euc"},
	{"charset": "utf-8", "name": "Universal Alphabet (UTF-8)"},
	{"charset": "windows-1250", "name": "Central European Alphabet (Windows)"},
	{"charset": "windows-1251", "name": "Cyrillic Alphabet (Windows)"},
	{"charset": "windows-1252", "name": "Western Alphabet (Windows)"},
	{"charset": "windows-1253", "name": "Greek Alphabet (Windows)"},
	{"charset": "windows-1254", "name": "Turkish Alphabet"},
	{"charset": "windows-1255", "name": "Hebrew Alphabet (Windows)"},
	{"charset": "windows-1256", "name": "Arabic Alphabet (Windows)"},
	{"charset": "windows-1257", "name": "Baltic Alphabet (Windows)"},
	{"charset": "windows-1258", "name": "Vietnamese Alphabet (Windows)"},
	{"charset": "windows-874", "name": "Thai (Windows)"},
}

数据来自 https://webcheatsheet.com/html/character_sets_list.php

View Source
var UsualCharsets = []maps.Map{
	{"charset": "utf-8", "name": "Universal Alphabet (UTF-8)"},
	{"charset": "unicode", "name": "Unicode"},
	{"name": "Chinese Simplified (GB2312)", "charset": "gb2312"},
	{"charset": "big5", "name": "Chinese Traditional (Big5)"},
	{"charset": "iso-8859-1", "name": "Western Alphabet"},
	{"charset": "euc-kr", "name": "Korean (EUC)"},
	{"charset": "shift-jis", "name": "Japanese (Shift-JIS)"},
	{"charset": "us-ascii", "name": "US-ASCII"},
}

Functions

func CopyStructObject

func CopyStructObject(destPtr, sourcePtr interface{})

CopyStructObject 拷贝同类型struct指针对象中的字段

func HasVariables

func HasVariables(source string) bool

HasVariables 判断是否有变量

func IPVersion added in v0.4.9

func IPVersion(netIP net.IP) int

IPVersion 获取IP版本号

func IsFuzzyDomain

func IsFuzzyDomain(domain string) bool

IsFuzzyDomain 判断是否为特殊域名

func IsIPv4 added in v0.4.9

func IsIPv4(netIP net.IP) bool

IsIPv4 检查是否为IPv4

func IsIPv6 added in v0.4.9

func IsIPv6(netIP net.IP) bool

IsIPv6 检查是否为IPv6

func LogError

func LogError(arg ...interface{})

记录错误

func MatchDomain

func MatchDomain(pattern string, domain string) (isMatched bool)

MatchDomain 匹配单个域名规则

func MatchDomains

func MatchDomains(patterns []string, domain string) (isMatched bool)

MatchDomains 从一组规则中匹配域名 支持的格式:example.com, www.example.com, .example.com, *.example.com, ~(\d+).example.com 更多参考:http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name

func MatchKeyword

func MatchKeyword(source, keyword string) bool

MatchKeyword 关键词匹配

func ParseVariables

func ParseVariables(source string, replacer func(varName string) (value string)) string

ParseVariables 分析变量

func ParseVariablesError added in v1.2.1

func ParseVariablesError(source string, replacer func(varName string) (value string, err error)) (string, error)

func ParseVariablesFromHolders

func ParseVariablesFromHolders(holders VariableHolders, replacer func(varName string) (value string)) string

ParseVariablesFromHolders 从占位中分析变量

func QuoteIP

func QuoteIP(ip string) string

QuoteIP 为IPv6加上括号

func UnmarshalYamlFile

func UnmarshalYamlFile(file string, ptr interface{}) error

Types

type BoolState

type BoolState = int8
const (
	BoolStateAll BoolState = 0 // 全部
	BoolStateYes BoolState = 1 // 已安装
	BoolStateNo  BoolState = 2 // 未安装
)

func ToBoolState

func ToBoolState(v interface{}) BoolState

type VariableHolder

type VariableHolder struct {
	Param     string
	Modifiers []string
}

VariableHolder 变量信息存储类型

type VariableHolders

type VariableHolders = []any

func ParseHolders

func ParseHolders(source string) (holders VariableHolders)

ParseHolders 分析占位

Jump to

Keyboard shortcuts

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