mylog

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 33 Imported by: 34

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/std/mylog.callWithHandler",
	"github.com/ddkwork/golibrary/std/mylog.Call",
}

Functions

func AlignString

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

func BaseName

func BaseName(path string) string

func Bool2Integer

func Bool2Integer[T Integer](b bool) T

func Call

func Call(f func())

func ChdirToGithubWorkspace

func ChdirToGithubWorkspace()

func Check

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

func Check2

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

func Check2Bool

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

func Check2ForJsonNumberNodeType

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

func Check2Ignore

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

func Check2IgnoreBool

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

func Check3

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

func Check3Bool

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

func Check4

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

func Check4Bool

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

func Check5

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

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

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

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

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

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

func CheckIgnore(err any)

func CheckNil

func CheckNil(ptr any)

func Copy

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

func CopyFile(path, dstPath string)

func CopyWithMask

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

func DirDepth(dirPath string) (depth int)

func DumpHex

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

func FileExists(path string) bool

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

func FileLineCountIsMoreThan

func FileLineCountIsMoreThan(path string, n int) bool

func FormatInteger

func FormatInteger[T Integer](data T) string

func FormatIntegerHex

func FormatIntegerHex[T Integer](data T) string

func FormatIntegerHex0x

func FormatIntegerHex0x[T Integer](data T) string

func FormatTime

func FormatTime(t time.Time) string

func GenA2Z

func GenA2Z() iter.Seq[string]

func GenMask

func GenMask()

func GetDaysDiff

func GetDaysDiff(dstTime string) string

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

func GetWindowsLogicalDrives() iter.Seq[string]

func GitProxy

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

func HomeDir() string

func Info

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

func Integer2Bool

func Integer2Bool[T Integer](value T) bool

func IntegerToIP

func IntegerToIP(ip int64) string

func IsASCIIDigit

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

func IsDirEx(path string) (ok bool)

func IsDirRoot

func IsDirRoot(path string) bool

func IsFilePath

func IsFilePath(path string) bool

func IsFilePathEx

func IsFilePathEx(path string) (ok bool)

func IsFreebsd

func IsFreebsd() bool

func IsIncludeLine

func IsIncludeLine(s string) bool

func IsIos

func IsIos() bool

func IsJs

func IsJs() bool

func IsLinux

func IsLinux() bool

func IsTermux

func IsTermux() bool

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 Json

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

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

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

func MarshalJSON(v any) []byte

func MarshalJson

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

func MarshalJsonToFile

func MarshalJsonToFile(v any, name string)

func New

func New() *log

func RandomAnySlice

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

func ReadFileToChunks

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

func ReadFileToLines

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

func ReflectVisibleFields

func ReflectVisibleFields(object any) iter.Seq2[int, reflect.StructField]

func RegexpWebBodyBlocks

func RegexpWebBodyBlocks(tagName string) string

func Request

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

func Response

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

func RunDir

func RunDir() string

func SetCallBack

func SetCallBack(callBack func(row string))

func SetDebug

func SetDebug(debug bool)

func Struct

func Struct(object any)

func Success

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

func Todo

func Todo(body any)

func Trace

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

func TrimExtension

func TrimExtension(path string) string

func ValueIsBytesType

func ValueIsBytesType(v reflect.Value) bool

func Warning

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

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

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

func (*Buffer) Append

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

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

func (*Buffer) CutWithIndex

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

func (*Buffer) Empty

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

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

func (*Buffer) Join

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

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

func (b *Buffer) ReWriteSelf()

func (*Buffer) ReWriteSelfGo

func (b *Buffer) ReWriteSelfGo()

func (*Buffer) ReadBinary

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

func (*Buffer) ReadN

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

func (*Buffer) ReaderGzip

func (b *Buffer) ReaderGzip() *Buffer

func (*Buffer) Replace

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

func (*Buffer) ReplaceAll

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

func (*Buffer) Reverse

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

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

func (*Buffer) TrimSpace

func (b *Buffer) TrimSpace() *Buffer

func (*Buffer) TrimSuffix

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 Complex

type Complex interface {
	~complex64 | ~complex128
}

type Float

type Float interface {
	~float32 | ~float64
}

type HexDumpString

type HexDumpString string

type HexString

type HexString string

type Integer

type Integer interface {
	Signed | Unsigned
}

type Ordered

type Ordered interface {
	Integer | Float | ~string
}

type Signed

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

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