mylog

package
v0.0.91 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: 38 Imported by: 43

Documentation

Index

Constants

View Source
const (
	FgHiBlack attribute = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

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

Variables

View Source
var (
	GithubWorkspace = os.Getenv("GITHUB_WORKSPACE")
	IsAction        = GithubWorkspace != ""
)
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 RegexpCenter = `(.+?)`
View Source
var RuntimePrefixesToFilter = []string{
	"runtime.",
	"testing.",
	"github.com/ddkwork/golibrary/mylog.callWithHandler",
	"github.com/ddkwork/golibrary/mylog.Call",
}
View Source
var Skips = []string{
	`vendor`,
	`\gioview\`,
	`\gio\`,
	`\gio-cmd\`,
	`\gio-example\`,
	`\gio-x\`,
	`\toolbox\`,
	`\unison\`,
	`\ux\patch\`,
}

Functions

func AlignString added in v0.0.56

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

func BaseName added in v0.0.56

func BaseName(path string) string

func Bool2Integer added in v0.0.87

func Bool2Integer[T Integer](b bool) T

func Call

func Call(f func())

func ChdirToGithubWorkspace added in v0.0.87

func ChdirToGithubWorkspace()

func Check

func Check[T any](result T) (isEof bool)

func Check2 added in v0.0.6

func Check2[T any](ret T, err error) T

func Check2Bool added in v0.0.6

func Check2Bool[T any](ret T, ok bool) T

func Check2ForJsonNumberNodeType added in v0.0.87

func Check2ForJsonNumberNodeType[T any](ret T, err error) bool

func Check2Ignore added in v0.0.6

func Check2Ignore[T any](ret T, err error) T

func Check3 added in v0.0.6

func Check3[T1 any, T2 any](ret1 T1, ret2 T2, err error) (T1, T2)

func Check3Bool added in v0.0.6

func Check3Bool[T1 any, T2 any](ret1 T1, ret2 T2, ok bool) (T1, T2)

func Check4 added in v0.0.6

func Check4[T1 any, T2 any, T3 any](ret1 T1, ret2 T2, ret3 T3, err error) (T1, T2, T3)

func Check4Bool added in v0.0.6

func Check4Bool[T1 any, T2 any, T3 any](ret1 T1, ret2 T2, ret3 T3, ok bool) (T1, T2, T3)

func Check5 added in v0.0.6

func Check5[T1 any, T2 any, T3 any, T4 any](ret1 T1, ret2 T2, ret3 T3, ret4 T4, err error) (T1, T2, T3, T4)

func Check5Bool added in v0.0.6

func Check5Bool[T1 any, T2 any, T3 any, T4 any](ret1 T1, ret2 T2, ret3 T3, ret4 T4, ok bool) (T1, T2, T3, T4)

func Check6 added in v0.0.6

func Check6[T1 any, T2 any, T3 any, T4 any, T5 any](ret1 T1, ret2 T2, ret3 T3, ret4 T4, ret5 T5, err error) (T1, T2, T3, T4, T5)

func Check6Bool added in v0.0.6

func Check6Bool[T1 any, T2 any, T3 any, T4 any, T5 any](ret1 T1, ret2 T2, ret3 T3, ret4 T4, ret5 T5, ok bool) (T1, T2, T3, T4, T5)

func Check7 added in v0.0.7

func Check7[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any](ret1 T1, ret2 T2, ret3 T3, ret4 T4, ret5 T5, ret6 T6, err error) (T1, T2, T3, T4, T5, T6)

func Check7Bool added in v0.0.7

func Check7Bool[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any](ret1 T1, ret2 T2, ret3 T3, ret4 T4, ret5 T5, ret6 T6, ok bool) (T1, T2, T3, T4, T5, T6)

func CheckIgnore added in v0.0.8

func CheckIgnore(err any)

func CheckNil

func CheckNil(ptr any)

func Concat added in v0.0.56

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

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

func CopyDir(dst, src string)

func CopyFile added in v0.0.56

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

func CreatDirectory(dir string) bool

func CurrentDirName added in v0.0.56

func CurrentDirName(path string) (currentDirName string)

func DirDepth added in v0.0.56

func DirDepth(dirPath string) (depth int)

func DumpHex added in v0.0.87

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

func DumpRequest

func DumpRequest(req *http.Request, body bool) string

func DumpResponse

func DumpResponse(resp *http.Response, body bool) string

func FileExists added in v0.0.91

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 FixFilePath added in v0.0.58

func FixFilePath(path string) string

func FormatAllFiles added in v0.0.53

func FormatAllFiles(noComments bool, path string)

func FormatDuration added in v0.0.56

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

func FormatTime(t time.Time) string

func GenA2Z added in v0.0.56

func GenA2Z() (letters []string)

func GenMask added in v0.0.87

func GenMask()

func GetDiffDays added in v0.0.56

func GetDiffDays(dstTime string) string

func GetLastReturnType added in v0.0.31

func GetLastReturnType(assignStmt *ast.AssignStmt) (lastReturnType string, b bool)

func GetPackageName added in v0.0.56

func GetPackageName() (pkgName string)

func GetTimeNowString added in v0.0.56

func GetTimeNowString() string

func GetTimeStamp added in v0.0.56

func GetTimeStamp() string

func GetTimeStamp13Bits added in v0.0.56

func GetTimeStamp13Bits() int64

func GetUserConfigDirs added in v0.0.56

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

func GetWindowsLogicalDrives added in v0.0.56

func GetWindowsLogicalDrives() []string

func GitProxy added in v0.0.87

func GitProxy(isSetProxy bool)

func Hex

func Hex[K keyType, V Unsigned](title K, v V) string

func HexDump

func HexDump[K keyType, V []byte | *bytes.Buffer](title K, buf V)

func HomeDir added in v0.0.56

func HomeDir() string

func Info

func Info[K keyType](title K, msg ...any)

func Integer2Bool added in v0.0.87

func Integer2Bool[T Integer](value T) bool

func IntegerToIP added in v0.0.56

func IntegerToIP(ip int64) string

func IsASCIIDigit added in v0.0.87

func IsASCIIDigit(s string) bool

func IsAndroid

func IsAndroid() bool

func IsDarwin added in v0.0.56

func IsDarwin() bool

func IsDir added in v0.0.56

func IsDir(path string) bool

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

func IsDirEx added in v0.0.56

func IsDirEx(path string) (ok bool)

func IsDirRoot added in v0.0.56

func IsDirRoot(path string) bool

func IsFilePath added in v0.0.56

func IsFilePath(path string) bool

func IsFilePathEx added in v0.0.56

func IsFilePathEx(path string) (ok bool)

func IsFreebsd added in v0.0.56

func IsFreebsd() bool

func IsIncludeLine added in v0.0.87

func IsIncludeLine(s string) bool

func IsIos added in v0.0.56

func IsIos() bool

func IsJs added in v0.0.56

func IsJs() bool

func IsLinux

func IsLinux() bool

func IsTermux added in v0.0.56

func IsTermux() bool

func IsWindows

func IsWindows() bool

func IsZero added in v0.0.56

func IsZero(v reflect.Value) bool

func JoinHomeDir added in v0.0.56

func JoinHomeDir(path string) (join string)

func JoinHomeFile added in v0.0.56

func JoinHomeFile(path string) (join string)

func Json

func Json[K keyType](title K, msg ...any)

func JsonIndent added in v0.0.56

func JsonIndent(b []byte) string

func Lines added in v0.0.56

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 MarshalJSON added in v0.0.56

func MarshalJSON(v any) []byte

func MarshalJson

func MarshalJson[K keyType](title K, msg any)

func MarshalJsonToFile added in v0.0.56

func MarshalJsonToFile(v any, name string)

func MoveFile added in v0.0.56

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

func New() *log

func RandomAny added in v0.0.56

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

func ReadFileToChunks added in v0.0.91

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

func ReadFileToLines added in v0.0.56

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

func ReflectVisibleFields added in v0.0.56

func ReflectVisibleFields(object any) []reflect.StructField

func RegexpWebBodyBlocks added in v0.0.56

func RegexpWebBodyBlocks(tagName string) string

func Request

func Request(Request *http.Request, body bool)

func Response

func Response(Response *http.Response, body bool)

func Row added in v0.0.91

func Row() string

func RunDir added in v0.0.56

func RunDir() string

func SetCallBack added in v0.0.87

func SetCallBack(callBack func())

func SetDebug

func SetDebug(debug bool)

func Struct

func Struct(object any)

func Success

func Success[K keyType](title K, msg ...any)

func Todo added in v0.0.52

func Todo(body string)

func Trace

func Trace[K keyType](title K, msg ...any)

func TrimExtension added in v0.0.56

func TrimExtension(path string) string

func UnFormatDuration added in v0.0.56

func UnFormatDuration(s string) time.Duration

func UnFormatTime added in v0.0.56

func UnFormatTime(s string) time.Time

func ValueIsBytesType added in v0.0.87

func ValueIsBytesType(v reflect.Value) bool

func Warning

func Warning[K keyType](title K, msg ...any)

func WriteAppend added in v0.0.56

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

func WriteBinaryFile added in v0.0.56

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

func WriteGoFile added in v0.0.56

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

func WriteGoFileWithDiff added in v0.0.23

func WriteGoFileWithDiff[T []byte](path string, data T)

func WriteTruncate added in v0.0.56

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

Types

type Buffer added in v0.0.56

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

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

func NewBuffer added in v0.0.56

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

func NewHexDump added in v0.0.56

func NewHexDump(hexdumpStr HexDumpString) (data *Buffer)

func NewHexString added in v0.0.56

func NewHexString(s HexString) *Buffer

func ReaderGzip added in v0.0.56

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

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

func (*Buffer) BigNumXorWithAlign added in v0.0.56

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

func (*Buffer) CheckDesBlockSize added in v0.0.56

func (b *Buffer) CheckDesBlockSize()

func (*Buffer) Contains added in v0.0.56

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

func (*Buffer) CutString added in v0.0.56

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

func (*Buffer) CutWithIndex added in v0.0.56

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

func (*Buffer) Empty added in v0.0.87

func (b *Buffer) Empty() bool

func (*Buffer) HexString added in v0.0.56

func (b *Buffer) HexString() HexString

func (*Buffer) HexStringUpper added in v0.0.56

func (b *Buffer) HexStringUpper() HexString

func (*Buffer) Indent added in v0.0.56

func (b *Buffer) Indent(deep int)

func (*Buffer) InsertByte added in v0.0.56

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

func (*Buffer) InsertBytes added in v0.0.56

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

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

func (b *Buffer) NewLine() *Buffer

func (*Buffer) ObjectBegin added in v0.0.56

func (b *Buffer) ObjectBegin()

func (*Buffer) ObjectEnd added in v0.0.56

func (b *Buffer) ObjectEnd()

func (*Buffer) Peek added in v0.0.87

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

func (*Buffer) Quote added in v0.0.56

func (b *Buffer) Quote()

func (*Buffer) QuoteWith added in v0.0.56

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

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

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

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

func (*Buffer) Reverse added in v0.0.87

func (b *Buffer) Reverse() *Buffer

func (*Buffer) SliceBegin added in v0.0.56

func (b *Buffer) SliceBegin()

func (*Buffer) SliceEnd added in v0.0.56

func (b *Buffer) SliceEnd()

func (*Buffer) ToLines added in v0.0.56

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

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

func (*Buffer) WriteBytesLn added in v0.0.56

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

func (*Buffer) WritePackageName added in v0.0.56

func (b *Buffer) WritePackageName()

func (*Buffer) WriteStringLn added in v0.0.56

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

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 HexDumpString added in v0.0.56

type HexDumpString string

type HexString added in v0.0.56

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

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

type Type added in v0.0.56

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

Jump to

Keyboard shortcuts

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