Documentation
¶
Index ¶
- Constants
- Variables
- func AlignString(s string, length int) (ss string)
- func Atoi(s string) int
- func BaseName(path string) string
- func Bool2Integer[T Integer](b bool) T
- func CapitalizeWords(s string) string
- func Concat[S ~[]E, E any](slices_ ...S) S
- func ConvertUtf82Gbk(src string) string
- func Copy(src, dst string)
- func CopyDir(dst, src string)
- func CopyFile(path, dstPath string)
- func CopyWithMask(src, dst string, mask fs.FileMode)
- func CreatDirectory(dir string) bool
- func CurrentDirName(path string) (currentDirName string)
- func DirDepth(dirPath string) (depth int)
- func DumpHex[T []byte | *bytes.Buffer](buf T) (dump string)
- func FileExists(path string) bool
- func FileLineCountIsMoreThan(path string, n int) bool
- func FileServer()
- func FileServerFS(fs embed.FS)
- func FirstToLower(in string) string
- func FirstToUpper(in string) string
- func FixFilePath(path string) string
- func Float64Cut(value float64, bits int) (float64, error)
- func Float64ToString(f float64, prec int) string
- func FormatDuration(d time.Duration) string
- func FormatInteger[T Integer](data T) string
- func FormatIntegerHex[T Integer](data T) string
- func FormatIntegerHex0x[T Integer](data T) string
- func FormatTime(t time.Time) string
- func GenA2Z() (letters []string)
- func GenMask()
- func GetAvailablePort() int
- func GetDesktopDir() string
- func GetDiffDays(dstTime string) string
- func GetLastCommitHashLocal(repositoryDir string) string
- func GetLocalIPs() []net.IP
- func GetPackageName() (pkgName string)
- func GetTimeNowString() string
- func GetTimeStamp() string
- func GetTimeStamp13Bits() int64
- func GetUserConfigDirs() (UserConfigDirs map[string]string)
- func GetWindowsLogicalDrives() []string
- func GitProxy(isSetProxy bool)
- func GoReleaser()
- func HomeDir() string
- func Integer2Bool[T Integer](value T) bool
- func IntegerToIP(ip int64) string
- func IsASCIIDigit(s string) bool
- func IsAndroid() bool
- func IsDarwin() bool
- func IsDir(path string) bool
- func IsDirEx(path string) (ok bool)
- func IsDirRoot(path string) bool
- func IsFilePath(path string) bool
- func IsFilePathEx(path string) (ok bool)
- func IsFreebsd() bool
- func IsIncludeLine(s string) bool
- func IsIos() bool
- func IsJs() bool
- func IsLinux() bool
- func IsPortAvailable(port int) bool
- func IsTermux() bool
- func IsTruthy(in string) bool
- func IsWindows() bool
- func IsZero(v reflect.Value) bool
- func JoinHomeDir(path string) (join string)
- func JoinHomeFile(path string) (join string)
- func JsonIndent(b []byte) string
- func Lines(s string) iter.Seq2[int, string]
- func LinesBytes(s []byte) iter.Seq2[int, []byte]
- func LoadImage(fileName string, fs embed.FS) image.Image
- func MarshalJSON(v any) []byte
- func MarshalJsonToFile(v any, name string)
- func MoveFile(src, dst string)
- func NaturalCmp(s1, s2 string, caseInsensitive bool) int
- func NaturalLess(s1, s2 string, caseInsensitive bool) bool
- func NewVersion[T string | uint64](s ...T) (v *object)
- func ParseFloat(sizeStr string) (size float64)
- func ParseGoMod(path string) *safemap.M[string, string]
- func ParseInt(s string) int64
- func ParseUint(s string) uint64
- func Permute[T comparable](data []T) [][]T
- func PermuteToUint32Slice(slice [][]byte) []uint32
- func RandomAny[T any](slice []T) T
- func ReadEmbedFileMap(embedFiles embed.FS, dir string) *safemap.M[string, []byte]
- func ReadFileToChunks(path string, n int) iter.Seq[[]byte]
- func ReadFileToLines(path string) iter.Seq[string]
- func ReflectVisibleFields(object any) []reflect.StructField
- func RegexpWebBodyBlocks(tagName string) string
- func RunDir() string
- func Slice(s any) []byte
- func SortStringsNaturalAscending(in []string)
- func SortStringsNaturalDescending(in []string)
- func StripBOM(b []byte) []byte
- func Struct(s any) []byte
- func ToCamel(data string) string
- func ToCamelToLower(s string) string
- func ToCamelUpper(s string) string
- func TopologicalSort[T comparable](m *safemap.M[T, []T], allowCyclicDependency bool) (sorted []T)
- func TrimExtension(path string) string
- func TrimSlash(name string) string
- func Uint32(s []uint32) []byte
- func UnFormatDuration(s string) time.Duration
- func UnFormatTime(s string) time.Time
- func Unquote(line string) string
- func UnquoteBytes(text []byte) []byte
- func Unquote_(text string) string
- func UpdateDependencies(path string)
- func UpdateDependenciesFromModFile(path string)
- func UpdateModsByWorkSpace(isUpdateAll bool)
- func ValueIsBytesType(v reflect.Value) bool
- func Wrap(prefix, text string, maxColumns int) string
- func WriteAppend[T Type](name string, data T)
- func WriteBinaryFile[T Type](name string, data T)
- func WriteGoFile[T Type](name string, data T)
- func WriteTruncate[T Type](name string, data T)
- type Buffer
- func (b *Buffer) Append(others ...*Buffer) *Buffer
- func (b *Buffer) AppendByteSlice(bytesSlice ...[]byte) []byte
- func (b *Buffer) BigNumXorWithAlign(arg1, arg2 []byte, align int) []byte
- func (b *Buffer) CheckDesBlockSize()
- func (b *Buffer) Contains(substr string) bool
- func (b *Buffer) CutString(left, right string) (cut string, found bool)
- func (b *Buffer) CutWithIndex(x, y int) []byte
- func (b *Buffer) Empty() bool
- func (b *Buffer) HexString() HexString
- func (b *Buffer) HexStringUpper() HexString
- func (b *Buffer) Indent(deep int)
- func (b *Buffer) InsertByte(index int, ch byte)
- func (b *Buffer) InsertBytes(index int, insert []byte)
- func (b *Buffer) InsertHeader(buf []byte) *Buffer
- func (b *Buffer) InsertString(index int, s string) *Buffer
- func (b *Buffer) Join(sep string, size int) string
- func (b *Buffer) NewLine() *Buffer
- func (b *Buffer) ObjectBegin()
- func (b *Buffer) ObjectEnd()
- func (b *Buffer) Peek(n int) []byte
- func (b *Buffer) Quote()
- func (b *Buffer) QuoteWith(s string) *Buffer
- func (b *Buffer) ReWriteSelf()
- func (b *Buffer) ReWriteSelfGo()
- func (b *Buffer) ReadBinary(order binary.ByteOrder) (data any)
- func (b *Buffer) ReadN(n int) []byte
- func (b *Buffer) ReaderGzip() *Buffer
- func (b *Buffer) Replace(old, new string, n int) *Buffer
- func (b *Buffer) ReplaceAll(old, new string) *Buffer
- func (b *Buffer) Reverse() *Buffer
- func (b *Buffer) SliceBegin()
- func (b *Buffer) SliceEnd()
- func (b *Buffer) ToLines() (lines iter.Seq[string])
- func (b *Buffer) TrimPrefix(prefix string) *Buffer
- func (b *Buffer) TrimSpace() *Buffer
- func (b *Buffer) TrimSuffix(suffix string) *Buffer
- func (b *Buffer) WriteBinary(order binary.ByteOrder, data any)
- func (b *Buffer) WriteBytesLn(buf []byte) *Buffer
- func (b *Buffer) WritePackageName()
- func (b *Buffer) WriteStringLn(s string) *Buffer
- type CommandSession
- type Complex
- type Float
- type GeneratedFile
- func (g *GeneratedFile) EnumTypes(name string, TypeTooltipMap *safemap.M[string, string])
- func (g *GeneratedFile) Format() string
- func (g *GeneratedFile) P(v ...any)
- func (g *GeneratedFile) PC(is64Bit bool, v string)
- func (g *GeneratedFile) PKeepSpace(v ...any)
- func (g *GeneratedFile) ReadTemplates(path, pkg string)
- func (g *GeneratedFile) SetCallBack(callBack func(is bool, v string) string)
- func (g *GeneratedFile) SetEnumBase(base int) *GeneratedFile
- func (g *GeneratedFile) SetEnumType(t reflect.Type) *GeneratedFile
- func (g *GeneratedFile) SetFilePath(filePath string) *GeneratedFile
- func (g *GeneratedFile) SetKeepOrigName(keepOrigName bool) *GeneratedFile
- func (g *GeneratedFile) SetPackageName(packageName string) *GeneratedFile
- func (g *GeneratedFile) SetValues(values []uint32) *GeneratedFile
- type HexDumpString
- type HexString
- type Integer
- type Ordered
- type Pool
- type Signed
- type Type
- type Unsigned
Constants ¶
const TimeLayout = "2006-01-02 15:04:05"
Variables ¶
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]+)`) )
var DefaultFileServerPort = ":8080"
var RegexpCenter = `(.+?)`
Functions ¶
func AlignString ¶
func Bool2Integer ¶ added in v0.0.87
func CapitalizeWords ¶ added in v0.0.91
CapitalizeWords capitalizes the first letter of each word in a string.
func ConvertUtf82Gbk ¶
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 CopyWithMask ¶ added in v0.0.91
CopyWithMask src to dst. src may be a directory, file, or symlink.
func CreatDirectory ¶
func CurrentDirName ¶
func FileExists ¶
FileExists returns true if the path points to a regular file.
func FileLineCountIsMoreThan ¶ added in v0.0.91
func FileServer ¶ added in v0.0.17
func FileServer()
func FileServerFS ¶ added in v0.0.17
func FirstToLower ¶ added in v0.0.91
FirstToLower converts the first character to lower case.
func FirstToUpper ¶ added in v0.0.91
FirstToUpper converts the first character to upper case.
func FixFilePath ¶ added in v0.0.58
func Float64ToString ¶
func FormatDuration ¶
func FormatInteger ¶ added in v0.0.87
func FormatIntegerHex ¶ added in v0.0.87
func FormatIntegerHex0x ¶ added in v0.0.87
func FormatTime ¶
func GetDesktopDir ¶ added in v0.0.91
func GetDesktopDir() string
func GetDiffDays ¶
func GetLastCommitHashLocal ¶ added in v0.0.91
func GetLocalIPs ¶ added in v0.0.17
func GetPackageName ¶
func GetPackageName() (pkgName string)
func GetTimeNowString ¶
func GetTimeNowString() string
func GetTimeStamp ¶
func GetTimeStamp() string
func GetTimeStamp13Bits ¶
func GetTimeStamp13Bits() int64
func GetUserConfigDirs ¶
func GetWindowsLogicalDrives ¶ added in v0.0.17
func GetWindowsLogicalDrives() []string
func GoReleaser ¶ added in v0.0.9
func GoReleaser()
func Integer2Bool ¶ added in v0.0.87
func IntegerToIP ¶
func IsASCIIDigit ¶ added in v0.0.87
func IsFilePath ¶
func IsFilePathEx ¶ added in v0.0.23
func IsIncludeLine ¶ added in v0.0.87
func IsPortAvailable ¶ added in v0.0.87
IsPortAvailable 判断端口是否可以(未被占用)
func IsTruthy ¶ added in v0.0.91
IsTruthy returns true for "truthy" values, i.e. ones that should be interpreted as true.
func JoinHomeDir ¶
func JoinHomeFile ¶
func JsonIndent ¶
func Lines ¶
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
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
LoadImage 一般而言,我们使用embed,对于进程图标,制作任务管理器和音速启动,直接得到image.Image 所以我们不用懒解码探测图片格式
func MarshalJSON ¶
func MarshalJsonToFile ¶
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
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
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 ParseFloat ¶
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 ReadEmbedFileMap ¶ added in v0.0.11
func ReflectVisibleFields ¶ added in v0.0.14
func ReflectVisibleFields(object any) []reflect.StructField
func RegexpWebBodyBlocks ¶
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 ToCamelToLower ¶
func ToCamelUpper ¶
func TopologicalSort ¶ added in v0.0.87
func TopologicalSort[T comparable](m *safemap.M[T, []T], allowCyclicDependency bool) (sorted []T)
func TrimExtension ¶
func UnFormatDuration ¶
func UnFormatTime ¶
func UnquoteBytes ¶ added in v0.0.91
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
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 Wrap ¶ added in v0.0.91
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 WriteBinaryFile ¶
func WriteGoFile ¶
func WriteTruncate ¶
Types ¶
type Buffer ¶
全排列 矩阵置换 拓扑排序 N叉树 treeGrid
func NewHexDump ¶
func NewHexDump(hexdumpStr HexDumpString) (data *Buffer)
func NewHexString ¶
func ReaderGzip ¶
func SwapAdjacent ¶ added in v0.0.87
func (*Buffer) AppendByteSlice ¶
func (*Buffer) BigNumXorWithAlign ¶
func (*Buffer) CheckDesBlockSize ¶
func (b *Buffer) CheckDesBlockSize()
func (*Buffer) CutWithIndex ¶
func (*Buffer) HexStringUpper ¶
func (*Buffer) InsertByte ¶
func (*Buffer) InsertBytes ¶
func (*Buffer) InsertHeader ¶ added in v0.0.91
InsertHeader insert to start,packetHeader
func (*Buffer) ObjectBegin ¶
func (b *Buffer) ObjectBegin()
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) ReaderGzip ¶
func (*Buffer) ReplaceAll ¶
func (*Buffer) SliceBegin ¶
func (b *Buffer) SliceBegin()
func (*Buffer) TrimPrefix ¶ added in v0.0.66
func (*Buffer) TrimSuffix ¶ added in v0.0.66
func (*Buffer) WriteBytesLn ¶
func (*Buffer) WritePackageName ¶
func (b *Buffer) WritePackageName()
func (*Buffer) WriteStringLn ¶
type CommandSession ¶ added in v0.0.16
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 GeneratedFile ¶
type GeneratedFile struct {
*Buffer
// contains filtered or unexported fields
}
func NewGeneratedFile ¶ added in v0.0.58
func NewGeneratedFile() (g *GeneratedFile)
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