stream

package
v0.0.90 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 40 Imported by: 14

Documentation

Index

Constants

View Source
const TimeLayout = "2006-01-02 15:04:05"

Variables

View Source
var (
	RegexpIp     = regexp.MustCompile(`((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))`)
	RegexpIpPort = regexp.MustCompile(`((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))):([0-9]+)`)
)
View Source
var DefaultFileServerPort = ":8080"
View Source
var RegexpCenter = `(.+?)`

Functions

func AlignString

func AlignString(s string, length int) (ss string)

func Atoi

func Atoi(s string) int

func BaseName

func BaseName(path string) string

func Bool2Integer added in v0.0.87

func Bool2Integer[T Integer](b bool) T

func Concat

func Concat[S ~[]E, E any](slices_ ...S) S

func ConvertUtf82Gbk

func ConvertUtf82Gbk(src string) string

func CopyDir

func CopyDir(dst, src string)

func CopyFile added in v0.0.50

func CopyFile(path, dstPath string)

func CreatDirectory

func CreatDirectory(dir string) bool

func CurrentDirName

func CurrentDirName(path string) (currentDirName string)

func DirDepth added in v0.0.6

func DirDepth(dirPath string) (depth int)

func DumpHex added in v0.0.87

func DumpHex[T []byte | *bytes.Buffer](buf T) (dump string)

func FileServer added in v0.0.17

func FileServer()

func FileServerFS added in v0.0.17

func FileServerFS(fs embed.FS)

func FixFilePath added in v0.0.58

func FixFilePath(path string) string

func Float64Cut

func Float64Cut(value float64, bits int) (float64, error)

func Float64ToString

func Float64ToString(f float64, prec int) string

func FormatDuration

func FormatDuration(d time.Duration) string

func FormatInteger added in v0.0.87

func FormatInteger[T Integer](data T) string

func FormatIntegerHex added in v0.0.87

func FormatIntegerHex[T Integer](data T) string

func FormatIntegerHex0x added in v0.0.87

func FormatIntegerHex0x[T Integer](data T) string

func FormatTime

func FormatTime(t time.Time) string

func Gbk2Utf8

func Gbk2Utf8(gbk string) (utf8 string)

func GenA2Z added in v0.0.17

func GenA2Z() (letters []string)

func GenMask added in v0.0.87

func GenMask()

func GetAvailablePort added in v0.0.87

func GetAvailablePort() int

GetAvailablePort 获取可用端口

func GetDiffDays

func GetDiffDays(dstTime string) string

func GetLocalIPs added in v0.0.17

func GetLocalIPs() []net.IP

func GetPackageName

func GetPackageName() (pkgName string)

func GetTimeNowString

func GetTimeNowString() string

func GetTimeStamp

func GetTimeStamp() string

func GetTimeStamp13Bits

func GetTimeStamp13Bits() int64

func GetUserConfigDirs

func GetUserConfigDirs() (UserConfigDirs map[string]string)

func GetWindowsLogicalDrives added in v0.0.17

func GetWindowsLogicalDrives() []string

func GitProxy

func GitProxy(isSetProxy bool)

func GoReleaser added in v0.0.9

func GoReleaser()

func HomeDir

func HomeDir() string

func Integer2Bool added in v0.0.87

func Integer2Bool[T Integer](value T) bool

func IntegerToIP

func IntegerToIP(ip int64) string

func IsASCIIAlpha added in v0.0.87

func IsASCIIAlpha(s string) bool

func IsASCIIDigit added in v0.0.87

func IsASCIIDigit(s string) bool

func IsAix

func IsAix() bool

func IsAlphanumeric added in v0.0.87

func IsAlphanumeric(s string) bool

func IsAndroid

func IsAndroid() bool

func IsDarwin

func IsDarwin() bool

func IsDir

func IsDir(path string) bool

func IsDirEx added in v0.0.50

func IsDirEx(path string) (ok bool)

func IsDirRoot added in v0.0.6

func IsDirRoot(path string) bool

func IsDragonfly

func IsDragonfly() bool

func IsFilePath

func IsFilePath(path string) bool

func IsFilePathEx added in v0.0.23

func IsFilePathEx(path string) (ok bool)

func IsFreebsd

func IsFreebsd() bool

func IsHurd

func IsHurd() bool

func IsIllumos

func IsIllumos() bool

func IsIncludeLine added in v0.0.87

func IsIncludeLine(s string) bool

func IsIos

func IsIos() bool

func IsJs

func IsJs() bool

func IsLinux

func IsLinux() bool

func IsNacl

func IsNacl() bool

func IsNetbsd

func IsNetbsd() bool

func IsOpenbsd

func IsOpenbsd() bool

func IsPlan9

func IsPlan9() bool

func IsPortAvailable added in v0.0.87

func IsPortAvailable(port int) bool

IsPortAvailable 判断端口是否可以(未被占用)

func IsSolaris

func IsSolaris() bool

func IsTermux

func IsTermux() bool

func IsWasip1

func IsWasip1() bool

func IsWindows

func IsWindows() bool

func IsZero

func IsZero(v reflect.Value) bool

func IsZos

func IsZos() bool

func JoinHomeDir

func JoinHomeDir(path string) (join string)

func JoinHomeFile

func JoinHomeFile(path string) (join string)

func JsonIndent

func JsonIndent(b []byte) string

func MarshalJSON

func MarshalJSON(v any) []byte

func MarshalJsonToFile

func MarshalJsonToFile(v any, name string)

func MoveFile

func MoveFile(src, dst string)

func NewVersion

func NewVersion[T string | uint64](s ...T) (v *object)

func ParseFloat

func ParseFloat(sizeStr string) (size float64)

func ParseInt

func ParseInt(s string) int64

func ParseUint

func ParseUint(s string) uint64

func Permute added in v0.0.87

func Permute[T comparable](data []T) [][]T

Permute 递归回溯法实现全排列 https://www.cnblogs.com/xwxz/p/14812448.html

func PermuteToUint32Slice added in v0.0.87

func PermuteToUint32Slice(slice [][]byte) []uint32

func RandomAny added in v0.0.13

func RandomAny[T any](slice []T) T

func ReadEmbedFileMap added in v0.0.11

func ReadEmbedFileMap(embedFiles embed.FS, dir string) *safemap.M[string, []byte]

func ReadFileToLines

func ReadFileToLines(path string) (lines []string)

func ReadLines

func ReadLines(fullPath string) ([]string, error)

func ReflectVisibleFields added in v0.0.14

func ReflectVisibleFields(object any) []reflect.StructField

func RegexpWebBodyBlocks

func RegexpWebBodyBlocks(tagName string) string

func RunDir

func RunDir() string

func SetNameAndEmail

func SetNameAndEmail(s *Buffer)

func SetProxy

func SetProxy(s *Buffer, isSetProxy bool)

func SetSafecrlf

func SetSafecrlf(s *Buffer)

func Slice added in v0.0.84

func Slice(s interface{}) []byte

Slice returns a byte slice view of a slice.

func SlicesIndex

func SlicesIndex(slice any, item any) int

func SlicesInsert

func SlicesInsert(slice any, index int, value any) any

func SplitFileByLines

func SplitFileByLines(filePath string, size int)

func Struct added in v0.0.84

func Struct(s interface{}) []byte

Struct returns a byte slice view of a struct.

func ToCamel

func ToCamel(data string, hasComment bool) string

func ToCamelToLower

func ToCamelToLower(s string, hasComment bool) string

func ToCamelUpper

func ToCamelUpper(s string, hasComment bool) string

func ToLines

func ToLines[T string | []byte | *os.File | *bytes.Buffer](data T) (lines []string)

func TopologicalSort added in v0.0.87

func TopologicalSort[T comparable](m *safemap.M[T, []T], allowCyclicDependency bool) (sorted []T)

func TrimExtension

func TrimExtension(path string) string

func TrimSlash added in v0.0.56

func TrimSlash(name string) string

func Uint32 added in v0.0.84

func Uint32(s []uint32) []byte

Uint32 returns a byte slice view of a uint32 slice.

func UnFormatDuration

func UnFormatDuration(s string) time.Duration

func UnFormatTime

func UnFormatTime(s string) time.Time

func Unquote

func Unquote(line string) string

func UpdateModsByWorkSpace

func UpdateModsByWorkSpace(isTidy, isUpdateAll bool, modWithCommitID ...string)

func Utf82Gbk

func Utf82Gbk(utf8 string) (gbk string)

func ValueIsBytesType added in v0.0.87

func ValueIsBytesType(v reflect.Value) bool

func WriteAppend

func WriteAppend[T Type](name string, data T)

func WriteBinaryFile

func WriteBinaryFile[T Type](name string, data T)

func WriteGoFile

func WriteGoFile[T Type](name string, data T)

func WriteLines

func WriteLines(lines []string, fullPath string) error

func WriteTruncate

func WriteTruncate[T Type](name string, data T)

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

全排列 矩阵置换 拓扑排序 N叉树 treeGrid

func NewBuffer

func NewBuffer[T Type](data T) *Buffer

func NewHexDump

func NewHexDump(hexdumpStr HexDumpString) (data *Buffer)

func NewHexString

func NewHexString(s HexString) *Buffer

func ReaderGzip

func ReaderGzip[T Type](data T) *Buffer

func SwapAdjacent added in v0.0.87

func SwapAdjacent[T Type](data T) *Buffer

func (*Buffer) Append added in v0.0.87

func (b *Buffer) Append(others ...*Buffer) *Buffer

func (*Buffer) AppendByteSlice

func (b *Buffer) AppendByteSlice(bytesSlice ...[]byte) []byte

func (*Buffer) AppendHeader added in v0.0.87

func (b *Buffer) AppendHeader(buf []byte) *Buffer

AppendHeader InsertToStart

func (*Buffer) BigNumXorWithAlign

func (b *Buffer) BigNumXorWithAlign(arg1, arg2 []byte, align int) (xorStream []byte)

func (*Buffer) CheckDesBlockSize

func (b *Buffer) CheckDesBlockSize()

func (*Buffer) Contains

func (b *Buffer) Contains(substr string) bool

func (*Buffer) CutString

func (b *Buffer) CutString(left, right string) (cut string, found bool)

func (*Buffer) CutWithIndex

func (b *Buffer) CutWithIndex(x, y int) []byte

func (*Buffer) Empty added in v0.0.87

func (b *Buffer) Empty() bool

func (*Buffer) HexString

func (b *Buffer) HexString() HexString

func (*Buffer) HexStringUpper

func (b *Buffer) HexStringUpper() HexString

func (*Buffer) Indent

func (b *Buffer) Indent(deep int)

func (*Buffer) InsertByte

func (b *Buffer) InsertByte(index int, ch byte)

func (*Buffer) InsertBytes

func (b *Buffer) InsertBytes(index int, insert []byte) []byte

func (*Buffer) InsertRune

func (b *Buffer) InsertRune(index int, r rune)

func (*Buffer) InsertString

func (b *Buffer) InsertString(index int, s string) *Buffer

func (*Buffer) Join added in v0.0.87

func (b *Buffer) Join(sep string, size int) string

func (*Buffer) LinesToString

func (b *Buffer) LinesToString(lines []string) string

func (*Buffer) NewLine

func (b *Buffer) NewLine() *Buffer

func (*Buffer) ObjectBegin

func (b *Buffer) ObjectBegin()

func (*Buffer) ObjectEnd

func (b *Buffer) ObjectEnd()

func (*Buffer) Peek added in v0.0.87

func (b *Buffer) Peek(n int) []byte

func (*Buffer) Quote

func (b *Buffer) Quote()

func (*Buffer) QuoteWith

func (b *Buffer) QuoteWith(s string) *Buffer

func (*Buffer) ReWriteSelf added in v0.0.87

func (b *Buffer) ReWriteSelf()

func (*Buffer) ReWriteSelfGo added in v0.0.87

func (b *Buffer) ReWriteSelfGo()

func (*Buffer) ReadBinary

func (b *Buffer) ReadBinary(order binary.ByteOrder) (data any)

func (*Buffer) ReadN added in v0.0.87

func (b *Buffer) ReadN(n int) []byte

func (*Buffer) ReaderGzip

func (b *Buffer) ReaderGzip() *Buffer

func (*Buffer) Replace added in v0.0.83

func (b *Buffer) Replace(old, new string, n int) *Buffer

func (*Buffer) ReplaceAll

func (b *Buffer) ReplaceAll(old, new string) *Buffer

func (*Buffer) ReplaceLine added in v0.0.71

func (b *Buffer) ReplaceLine(index int, line string) *Buffer

func (*Buffer) Reverse added in v0.0.87

func (b *Buffer) Reverse() *Buffer

func (*Buffer) SliceBegin

func (b *Buffer) SliceBegin()

func (*Buffer) SliceEnd

func (b *Buffer) SliceEnd()

func (*Buffer) ToLines

func (b *Buffer) ToLines() (lines []string)

func (*Buffer) TrimPrefix added in v0.0.66

func (b *Buffer) TrimPrefix(prefix string) *Buffer

func (*Buffer) TrimSpace added in v0.0.66

func (b *Buffer) TrimSpace() *Buffer

func (*Buffer) TrimSuffix added in v0.0.66

func (b *Buffer) TrimSuffix(suffix string) *Buffer

func (*Buffer) WriteBinary

func (b *Buffer) WriteBinary(order binary.ByteOrder, data any)

func (*Buffer) WriteBytesLn

func (b *Buffer) WriteBytesLn(buf []byte) *Buffer

func (*Buffer) WritePackageName

func (b *Buffer) WritePackageName()

func (*Buffer) WriteStringLn

func (b *Buffer) WriteStringLn(s string) *Buffer

type CommandSession added in v0.0.16

type CommandSession struct {
	Output           *Buffer
	Error            *Buffer
	CurrentDirectory string
}

func RunCommand

func RunCommand(command string) (session *CommandSession)

func RunCommandArgs added in v0.0.16

func RunCommandArgs(arg ...string) *CommandSession

type Complex added in v0.0.87

type Complex interface {
	~complex64 | ~complex128
}

type Float added in v0.0.87

type Float interface {
	~float32 | ~float64
}

type GeneratedFile

type GeneratedFile struct {
	*Buffer
	// contains filtered or unexported fields
}

func NewGeneratedFile added in v0.0.58

func NewGeneratedFile() (g *GeneratedFile)

func (*GeneratedFile) EnumTypes added in v0.0.87

func (g *GeneratedFile) EnumTypes(name string, TypeTooltipMap *safemap.M[string, string])

func (*GeneratedFile) Format added in v0.0.87

func (g *GeneratedFile) Format() string

func (*GeneratedFile) P

func (g *GeneratedFile) P(v ...any)

func (*GeneratedFile) PC added in v0.0.87

func (g *GeneratedFile) PC(is64Bit bool, v string)

func (*GeneratedFile) ReadTemplates

func (g *GeneratedFile) ReadTemplates(path, pkg string)

func (*GeneratedFile) SetCallBack added in v0.0.87

func (g *GeneratedFile) SetCallBack(callBack func(is bool, v string) string)

func (*GeneratedFile) SetEnumBase added in v0.0.87

func (g *GeneratedFile) SetEnumBase(base int) *GeneratedFile

func (*GeneratedFile) SetEnumType added in v0.0.87

func (g *GeneratedFile) SetEnumType(t reflect.Type) *GeneratedFile

func (*GeneratedFile) SetFilePath added in v0.0.83

func (g *GeneratedFile) SetFilePath(filePath string) *GeneratedFile

func (*GeneratedFile) SetKeepOrigName added in v0.0.87

func (g *GeneratedFile) SetKeepOrigName(keepOrigName bool) *GeneratedFile

func (*GeneratedFile) SetPackageName added in v0.0.83

func (g *GeneratedFile) SetPackageName(packageName string) *GeneratedFile

func (*GeneratedFile) SetValues added in v0.0.87

func (g *GeneratedFile) SetValues(values []uint32) *GeneratedFile

type HexDumpString

type HexDumpString string

type HexString

type HexString string

type Integer added in v0.0.87

type Integer interface {
	Signed | Unsigned
}

type Ordered added in v0.0.87

type Ordered interface {
	Integer | Float | ~string
}

type Pool added in v0.0.28

type Pool[T any] struct {
	// contains filtered or unexported fields
}

func NewPool added in v0.0.28

func NewPool[T any](fn func() T) *Pool[T]

func (*Pool[T]) Get added in v0.0.28

func (p *Pool[T]) Get() T

func (*Pool[T]) Put added in v0.0.28

func (p *Pool[T]) Put(v T)

type Signed added in v0.0.87

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Type

type Type interface {
	string | HexString | HexDumpString | ~[]byte | cmp.Ordered | ~*bytes.Buffer | *big.Int | *Buffer
}

全排列 矩阵置换 拓扑排序 N叉树 treeGrid

type Unsigned added in v0.0.87

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Jump to

Keyboard shortcuts

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