stream

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: Apache-2.0 Imports: 48 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 CapitalizeWords added in v0.0.91

func CapitalizeWords(s string) string

CapitalizeWords capitalizes the first letter of each word in a string.

func Concat

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

func ConvertUtf82Gbk

func ConvertUtf82Gbk(src string) string

func Copy added in v0.0.91

func Copy(src, dst string)

Copy src to dst. src may be a directory, file, or symlink.

func CopyDir

func CopyDir(dst, src string)

func CopyFile added in v0.0.50

func CopyFile(path, dstPath string)

func CopyWithMask added in v0.0.91

func CopyWithMask(src, dst string, mask fs.FileMode)

CopyWithMask src to dst. src may be a directory, file, or symlink.

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 FileExists

func FileExists(path string) bool

FileExists returns true if the path points to a regular file.

func FileLineCountIsMoreThan added in v0.0.91

func FileLineCountIsMoreThan(path string, n int) bool

func FileServer added in v0.0.17

func FileServer()

func FileServerFS added in v0.0.17

func FileServerFS(fs embed.FS)

func FirstToLower added in v0.0.91

func FirstToLower(in string) string

FirstToLower converts the first character to lower case.

func FirstToUpper added in v0.0.91

func FirstToUpper(in string) string

FirstToUpper converts the first character to upper case.

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 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 GetDesktopDir added in v0.0.91

func GetDesktopDir() string

func GetDiffDays

func GetDiffDays(dstTime string) string

func GetLastCommitHashLocal added in v0.0.91

func GetLastCommitHashLocal(repositoryDir 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 IsASCIIDigit added in v0.0.87

func IsASCIIDigit(s string) bool

func IsAndroid

func IsAndroid() bool

func IsDarwin

func IsDarwin() bool

func IsDir

func IsDir(path string) bool

IsDir returns true if the specified path exists and is a directory.

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 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 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 IsPortAvailable added in v0.0.87

func IsPortAvailable(port int) bool

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

func IsTermux

func IsTermux() bool

func IsTruthy added in v0.0.91

func IsTruthy(in string) bool

IsTruthy returns true for "truthy" values, i.e. ones that should be interpreted as true.

func IsWindows

func IsWindows() bool

func IsZero

func IsZero(v reflect.Value) 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 Lines

func Lines(s string) iter.Seq2[int, string]

Lines returns an iterator over the newline-terminated lines in the string s. The lines yielded by the iterator include their terminating newlines. If s is empty, the iterator yields no lines at all. If s does not end in a newline, the final yielded line will not end in a newline. It returns a single-use iterator with both line number and line content.

func LinesBytes added in v0.0.91

func LinesBytes(s []byte) iter.Seq2[int, []byte]

LinesBytes returns an iterator over the newline-terminated lines in the byte slice s. The lines yielded by the iterator include their terminating newlines. If s is empty, the iterator yields no lines at all. If s does not end in a newline, the final yielded line will not end in a newline. It returns a single-use iterator.

func LoadImage added in v0.0.91

func LoadImage(fileName string, fs embed.FS) image.Image

LoadImage 一般而言,我们使用embed,对于进程图标,制作任务管理器和音速启动,直接得到image.Image 所以我们不用懒解码探测图片格式

func MarshalJSON

func MarshalJSON(v any) []byte

func MarshalJsonToFile

func MarshalJsonToFile(v any, name string)

func MoveFile

func MoveFile(src, dst string)

MoveFile moves a file in the file system or across volumes, using rename if possible, but falling back to copying the file if not. This will error if either src or dst are not regular files.

func NaturalCmp added in v0.0.91

func NaturalCmp(s1, s2 string, caseInsensitive bool) int

NaturalCmp compares two strings using natural ordering. This means that "a2" < "a12".

Non-digit sequences and numbers are compared separately. The former are compared byte-wise, while the latter are compared numerically (except that the number of leading zeros is used as a tie-breaker, so "2" < "02").

Limitations:

  • only ASCII digits (0-9) are considered.

Original algorithm: https://github.com/fvbommel/util/blob/master/sortorder/natsort.go

func NaturalLess added in v0.0.91

func NaturalLess(s1, s2 string, caseInsensitive bool) bool

NaturalLess compares two strings using natural ordering. This means that "a2" < "a12".

Non-digit sequences and numbers are compared separately. The former are compared byte-wise, while the latter are compared numerically (except that the number of leading zeros is used as a tie-breaker, so "2" < "02").

Limitations:

  • only ASCII digits (0-9) are considered.

Original algorithm: https://github.com/fvbommel/util/blob/master/sortorder/natsort.go

func NewVersion

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

func ParseFloat

func ParseFloat(sizeStr string) (size float64)

func ParseGoMod added in v0.0.91

func ParseGoMod(path string) *safemap.M[string, string]

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 ReadFileToChunks added in v0.0.91

func ReadFileToChunks(path string, n int) iter.Seq[[]byte]

func ReadFileToLines

func ReadFileToLines(path string) iter.Seq[string]

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 Slice added in v0.0.84

func Slice(s any) []byte

Slice returns a byte slice view of a slice.

func SortStringsNaturalAscending added in v0.0.91

func SortStringsNaturalAscending(in []string)

SortStringsNaturalAscending sorts a slice of strings using NaturalLess in least to most order.

func SortStringsNaturalDescending added in v0.0.91

func SortStringsNaturalDescending(in []string)

SortStringsNaturalDescending sorts a slice of strings using NaturalLess in most to least order.

func StripBOM added in v0.0.91

func StripBOM(b []byte) []byte

StripBOM removes the BOM marker from UTF-8 data, if present.

func Struct added in v0.0.84

func Struct(s any) []byte

Struct returns a byte slice view of a struct.

func ToCamel

func ToCamel(data string) string

func ToCamelToLower

func ToCamelToLower(s string) string

func ToCamelUpper

func ToCamelUpper(s string) 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 UnquoteBytes added in v0.0.91

func UnquoteBytes(text []byte) []byte

UnquoteBytes strips up to one set of surrounding double quotes from the bytes and returns them as a string. For a more capable version that supports different quoting types and unescaping, consider using strconv.Unquote().

func Unquote_ added in v0.0.91

func Unquote_(text string) string

Unquote strips up to one set of surrounding double quotes from the bytes and returns them as a string. For a more capable version that supports different quoting types and unescaping, consider using strconv.Unquote().

func UpdateDependencies added in v0.0.91

func UpdateDependencies(path string)

func UpdateDependenciesFromModFile added in v0.0.91

func UpdateDependenciesFromModFile(path string)

func UpdateModsByWorkSpace

func UpdateModsByWorkSpace(isUpdateAll bool)

func ValueIsBytesType added in v0.0.87

func ValueIsBytesType(v reflect.Value) bool

func Wrap added in v0.0.91

func Wrap(prefix, text string, maxColumns int) string

Wrap text to a certain length, giving it an optional prefix on each line. Words will not be broken, even if they exceed the maximum column size and instead will extend past the desired length.

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 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) BigNumXorWithAlign

func (b *Buffer) BigNumXorWithAlign(arg1, arg2 []byte, align int) []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)

func (*Buffer) InsertHeader added in v0.0.91

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

InsertHeader insert to start,packetHeader

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) 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) 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 iter.Seq[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

func RunCommandWithDir added in v0.0.91

func RunCommandWithDir(command, dir string) (session *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) PKeepSpace added in v0.0.91

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

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
}

Directories

Path Synopsis
x command
Package desktop provides desktop integration utilities.
Package desktop provides desktop integration utilities.
net

Jump to

Keyboard shortcuts

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