Documentation
¶
Index ¶
- Constants
- Variables
- func AlignString(s string, length int) (ss string)
- func Atoi(s string) int
- func BaseName(path string) string
- func CapitalizeWords(s string) string
- func ConvertUtf82Gbk(src string) string
- func Copy(src, dst string)
- func CopyDir(src, dst 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 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 Fix(dir string)
- func Float64Cut(value float64, bits int) (float64, error)
- func Float64ToString(f float64, prec int) string
- func Fmt(dir string)
- func FormatTime(t time.Time) string
- func GenA2Z() iter.Seq[string]
- func GenMask()
- func GetAvailablePort() int
- func GetDaysDiff(dstTime string) string
- func GetDesktopDir() 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() iter.Seq[string]
- func GitProxy(isSetProxy bool)
- func GoReleaser()
- func HomeDir() string
- func IntegerToIP(ip int64) string
- 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 IsIos() bool
- func IsJs() bool
- func IsLinux() bool
- func IsPortAvailable(port int) bool
- func IsRunningOnGitHubActions() 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 MarshalJSON(v any) []byte
- func MarshalJsonToFile(v any, name 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(file string, data []byte) *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 RandomAnySlice[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) iter.Seq2[int, reflect.StructField]
- func RegexpWebBodyBlocks(tagName string) string
- func RunCommands(commands 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 Unquote(line string) string
- func UnquoteBytes(text []byte) []byte
- func Unquote_(text string) string
- func UpdateAllLocalRep()
- func UpdateWorkSpace(isUpdateAll 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) Contains(substr string) 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) 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 GeneratedFile
- func NewGeneratedFile() (g *GeneratedFile)
- func RunCommand(arg ...string) (stdOut *GeneratedFile)
- func RunCommandSafe(arg ...string) (stdOut *GeneratedFile)
- func RunCommandSilent(arg ...string) (stdOut *GeneratedFile)
- func RunCommandWithDir(dir string, arg ...string) (stdOut *GeneratedFile)
- func RunCommandWithDirSilent(dir string, arg ...string) (stdOut *GeneratedFile)
- func (g *GeneratedFile) AddImport(pkg string)
- func (g *GeneratedFile) EnumTypes(name string, TypeTooltipMap *safemap.M[string, string])
- func (g *GeneratedFile) Format() string
- func (g *GeneratedFile) InsertPackageWithImports(packageName string) *GeneratedFile
- 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 Pool
- type Type
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 CapitalizeWords ¶
CapitalizeWords capitalizes the first letter of each word in a string.
func ConvertUtf82Gbk ¶
func CopyWithMask ¶
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 ¶
func FileServer ¶
func FileServer()
func FileServerFS ¶
func FirstToLower ¶
FirstToLower converts the first character to lower case.
func FirstToUpper ¶
FirstToUpper converts the first character to upper case.
func Float64ToString ¶
func FormatTime ¶
func GetDaysDiff ¶
func GetDesktopDir ¶
func GetDesktopDir() string
func GetLastCommitHashLocal ¶
func GetLocalIPs ¶
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 ¶
func GoReleaser ¶
func GoReleaser()
func IntegerToIP ¶
func IsFilePath ¶
func IsFilePathEx ¶
func IsRunningOnGitHubActions ¶ added in v0.1.5
func IsRunningOnGitHubActions() bool
func IsTruthy ¶
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 ¶
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 MarshalJSON ¶
func MarshalJsonToFile ¶
func NaturalCmp ¶
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 ¶
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 ¶
func Permute[T comparable](data []T) [][]T
Permute 递归回溯法实现全排列 https://www.cnblogs.com/xwxz/p/14812448.html
func PermuteToUint32Slice ¶
func RandomAnySlice ¶
func RandomAnySlice[T any](slice []T) T
func ReadEmbedFileMap ¶
func ReflectVisibleFields ¶
func RegexpWebBodyBlocks ¶
func RunCommands ¶ added in v0.1.5
func RunCommands(commands string)
func SortStringsNaturalAscending ¶
func SortStringsNaturalAscending(in []string)
SortStringsNaturalAscending sorts a slice of strings using NaturalLess in least to most order.
func SortStringsNaturalDescending ¶
func SortStringsNaturalDescending(in []string)
SortStringsNaturalDescending sorts a slice of strings using NaturalLess in most to least order.
func ToCamelToLower ¶
func ToCamelUpper ¶
func TopologicalSort ¶
func TopologicalSort[T comparable](m *safemap.M[T, []T], allowCyclicDependency bool) (sorted []T)
func TrimExtension ¶
func UnquoteBytes ¶
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_ ¶
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 UpdateAllLocalRep ¶
func UpdateAllLocalRep()
func UpdateWorkSpace ¶
func UpdateWorkSpace(isUpdateAll bool)
func Wrap ¶
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 ¶
func (*Buffer) AppendByteSlice ¶
func (*Buffer) BigNumXorWithAlign ¶
func (*Buffer) CutWithIndex ¶
func (*Buffer) HexStringUpper ¶
func (*Buffer) InsertByte ¶
func (*Buffer) InsertBytes ¶
func (*Buffer) ObjectBegin ¶
func (b *Buffer) ObjectBegin()
func (*Buffer) ReWriteSelf ¶
func (b *Buffer) ReWriteSelf()
func (*Buffer) ReWriteSelfGo ¶
func (b *Buffer) ReWriteSelfGo()
func (*Buffer) ReaderGzip ¶
func (*Buffer) ReplaceAll ¶
func (*Buffer) SliceBegin ¶
func (b *Buffer) SliceBegin()
func (*Buffer) TrimPrefix ¶
func (*Buffer) TrimSuffix ¶
func (*Buffer) WriteBytesLn ¶
func (*Buffer) WritePackageName ¶
func (b *Buffer) WritePackageName()
func (*Buffer) WriteStringLn ¶
type GeneratedFile ¶
type GeneratedFile struct {
*Buffer
// contains filtered or unexported fields
}
func NewGeneratedFile ¶
func NewGeneratedFile() (g *GeneratedFile)
func RunCommand ¶
func RunCommand(arg ...string) (stdOut *GeneratedFile)
func RunCommandSafe ¶ added in v0.1.4
func RunCommandSafe(arg ...string) (stdOut *GeneratedFile)
func RunCommandSilent ¶ added in v0.1.5
func RunCommandSilent(arg ...string) (stdOut *GeneratedFile)
func RunCommandWithDir ¶
func RunCommandWithDir(dir string, arg ...string) (stdOut *GeneratedFile)
func RunCommandWithDirSilent ¶ added in v0.1.5
func RunCommandWithDirSilent(dir string, arg ...string) (stdOut *GeneratedFile)
func (*GeneratedFile) AddImport ¶
func (g *GeneratedFile) AddImport(pkg string)
func (*GeneratedFile) Format ¶
func (g *GeneratedFile) Format() string
func (*GeneratedFile) InsertPackageWithImports ¶
func (g *GeneratedFile) InsertPackageWithImports(packageName string) *GeneratedFile
func (*GeneratedFile) P ¶
func (g *GeneratedFile) P(v ...any)
func (*GeneratedFile) PC ¶
func (g *GeneratedFile) PC(is64Bit bool, v string)
func (*GeneratedFile) PKeepSpace ¶
func (g *GeneratedFile) PKeepSpace(v ...any)
func (*GeneratedFile) ReadTemplates ¶
func (g *GeneratedFile) ReadTemplates(path, pkg string)
func (*GeneratedFile) SetCallBack ¶
func (g *GeneratedFile) SetCallBack(callBack func(is bool, v string) string)
func (*GeneratedFile) SetEnumBase ¶
func (g *GeneratedFile) SetEnumBase(base int) *GeneratedFile
func (*GeneratedFile) SetEnumType ¶
func (g *GeneratedFile) SetEnumType(t reflect.Type) *GeneratedFile
func (*GeneratedFile) SetFilePath ¶
func (g *GeneratedFile) SetFilePath(filePath string) *GeneratedFile
func (*GeneratedFile) SetKeepOrigName ¶
func (g *GeneratedFile) SetKeepOrigName(keepOrigName bool) *GeneratedFile
func (*GeneratedFile) SetPackageName ¶ added in v0.1.5
func (g *GeneratedFile) SetPackageName(packageName string) *GeneratedFile
func (*GeneratedFile) SetValues ¶
func (g *GeneratedFile) SetValues(values []uint32) *GeneratedFile
type HexDumpString ¶
type HexDumpString string