util

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllEncodings = map[string]encoding.Encoding{

	"nop":   encoding.Nop,
	"plain": encoding.Nop,
	"utf-8": encoding.Nop,

	"gbk":      simplifiedchinese.GBK,
	"gb18030":  simplifiedchinese.GB18030,
	"hzgb2312": simplifiedchinese.HZGB2312,

	"big5": traditionalchinese.Big5,

	"euc-jp":     japanese.EUCJP,
	"iso2022-jp": japanese.ISO2022JP,
	"shift-jis":  japanese.ShiftJIS,

	"euc-kr": korean.EUCKR,

	"iso8859-6e": charmap.ISO8859_6E,
	"iso8859-6i": charmap.ISO8859_6I,
	"iso8859-8e": charmap.ISO8859_8E,
	"iso8859-8i": charmap.ISO8859_8I,

	"iso8859-1":  charmap.ISO8859_1,
	"iso8859-2":  charmap.ISO8859_2,
	"iso8859-3":  charmap.ISO8859_3,
	"iso8859-4":  charmap.ISO8859_4,
	"iso8859-5":  charmap.ISO8859_5,
	"iso8859-6":  charmap.ISO8859_6,
	"iso8859-7":  charmap.ISO8859_7,
	"iso8859-8":  charmap.ISO8859_8,
	"iso8859-9":  charmap.ISO8859_9,
	"iso8859-10": charmap.ISO8859_10,
	"iso8859-13": charmap.ISO8859_13,
	"iso8859-14": charmap.ISO8859_14,
	"iso8859-15": charmap.ISO8859_15,
	"iso8859-16": charmap.ISO8859_16,

	"cp437":       charmap.CodePage437,
	"cp850":       charmap.CodePage850,
	"cp852":       charmap.CodePage852,
	"cp855":       charmap.CodePage855,
	"cp858":       charmap.CodePage858,
	"cp860":       charmap.CodePage860,
	"cp862":       charmap.CodePage862,
	"cp863":       charmap.CodePage863,
	"cp865":       charmap.CodePage865,
	"cp866":       charmap.CodePage866,
	"ebcdic-037":  charmap.CodePage037,
	"ebcdic-1040": charmap.CodePage1140,
	"ebcdic-1047": charmap.CodePage1047,

	"koi8r": charmap.KOI8R,
	"koi8u": charmap.KOI8U,

	"macintosh":          charmap.Macintosh,
	"macintosh-cyrillic": charmap.MacintoshCyrillic,

	"windows1250": charmap.Windows1250,
	"windows1251": charmap.Windows1251,
	"windows1252": charmap.Windows1252,
	"windows1253": charmap.Windows1253,
	"windows1254": charmap.Windows1254,
	"windows1255": charmap.Windows1255,
	"windows1256": charmap.Windows1256,
	"windows1257": charmap.Windows1257,
	"windows1258": charmap.Windows1258,
	"windows874":  charmap.Windows874,

	"utf-16be-bom": unicode.UTF16(unicode.BigEndian, unicode.UseBOM),
	"utf-16le-bom": unicode.UTF16(unicode.LittleEndian, unicode.UseBOM),
}

Functions

func Abs

func Abs(n int64) int64

func AsyncRunGroup added in v1.3.0

func AsyncRunGroup(taskName string, namedJobs map[string]func())

func AsyncRunWithTimeout

func AsyncRunWithTimeout(f func(), timeout time.Duration)

func ByteToStringUnsafe

func ByteToStringUnsafe(b []byte) string

func Clone

func Clone(from, to interface{}) error

func CompilePatternWithJavaStyle

func CompilePatternWithJavaStyle(pattern string) (*regexp.Regexp, error)

func Contain

func Contain(code string, array []string) bool

func ContainWithFunc

func ContainWithFunc(code string, array []CodeFunc) bool

func Encode added in v1.3.0

func Encode(charset string, context []byte) ([]byte, error)

func GlobWithRecursive

func GlobWithRecursive(pattern string) (matches []string, err error)

func Is2xxSuccess added in v1.5.0

func Is2xxSuccess(code int) bool

func LineCount

func LineCount(r io.Reader) (int, error)

LineCount returns the number of file lines better

func LineCount1

func LineCount1(r io.Reader) (int, error)

LineCount1 returns the number of file lines deprecated

func LineCountTo

func LineCountTo(offset int64, fileName string) (int, error)

LineCountTo calculates the number of lines to the offset

func MatchGroup

func MatchGroup(pattern string, context string) (paramsMap map[string]string)

func MatchGroupWithRegex

func MatchGroupWithRegex(compRegEx *regexp.Regexp, context string) (paramsMap map[string]string)

func MatchGroupWithRegexAndHeader added in v1.3.0

func MatchGroupWithRegexAndHeader(compRegEx *regexp.Regexp, context string, header map[string]interface{}) int

func MatchWithRecursive

func MatchWithRecursive(pattern, name string) (matched bool, err error)

func MustCompilePatternWithJavaStyle added in v1.3.0

func MustCompilePatternWithJavaStyle(pattern string) *regexp.Regexp

func SplitGlobPattern added in v1.4.0

func SplitGlobPattern(p string) (base, pattern string)

func StringToByteUnsafe

func StringToByteUnsafe(s string) []byte

func WriteFileOrCreate

func WriteFileOrCreate(dir string, filename string, content []byte) error

Types

type CodeFunc

type CodeFunc interface {
	Code() string
}

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

func Compile

func Compile(pattern string) (Matcher, error)

func MustCompile

func MustCompile(pattern string) Matcher

Directories

Path Synopsis
reg

Jump to

Keyboard shortcuts

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