mylog

package
v0.0.84 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 39 Imported by: 43

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 RegexpCenter = `(.+?)`
View Source
var RuntimePrefixesToFilter = []string{
	"runtime.",
	"testing.",
	"github.com/ddkwork/golibrary/mylog.callWithHandler",
	"github.com/ddkwork/golibrary/mylog.Call",
}

Functions

func AlignString added in v0.0.56

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

func Atoi added in v0.0.56

func Atoi(s string) int

func BaseName added in v0.0.56

func BaseName(path string) string

func Body

func Body() string

func Call

func Call(f func())

func Check

func Check[T any](result T)

func Check2 added in v0.0.6

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

func Check2Bool added in v0.0.6

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

func Check2Ignore added in v0.0.6

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

func Check3 added in v0.0.6

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

func Check3Bool added in v0.0.6

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

func Check4 added in v0.0.6

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

func Check4Bool added in v0.0.6

func Check4Bool[T1 any, T2 any, T3 any](ret1 T1, ret2 T2, ret3 T3, ok bool) (r1 T1, r2 T2, r3 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) (r1 T1, r2 T2, r3 T3, r4 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) (r1 T1, r2 T2, r3 T3, r4 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) (r1 T1, r2 T2, r3 T3, r4 T4, r5 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) (r1 T1, r2 T2, r3 T3, r4 T4, r5 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) (r1 T1, r2 T2, r3 T3, r4 T4, r5 T5, r6 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) (r1 T1, r2 T2, r3 T3, r4 T4, r5 T5, r6 T6)

func CheckEof added in v0.0.47

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

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

func CopyDir(dst, src string)

func CopyFile added in v0.0.56

func CopyFile(path, dstPath string)

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

func CutUint16(u uint16) uint8

func CutUint16_ added in v0.0.56

func CutUint16_(u uint16) uint8

func Diff

func Diff(oldName string, old []byte, newName string, new []byte) []byte

func DirDepth added in v0.0.56

func DirDepth(dirPath string) (depth int)

func DumpRequest

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

func DumpResponse

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

func FixFilePath added in v0.0.58

func FixFilePath(path string) string

func Float64Cut added in v0.0.56

func Float64Cut(value float64, bits int) (float64, error)

func Float64ToString added in v0.0.56

func Float64ToString(f float64, prec int) string

func FormatAllFiles added in v0.0.53

func FormatAllFiles()

func FormatAllFilesNoComments added in v0.0.53

func FormatAllFilesNoComments()

func FormatDuration added in v0.0.56

func FormatDuration(d time.Duration) 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 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 Hex

func Hex[T constraints.Integer | []byte | *bytes.Buffer](title string, msg T) string

func HexDump

func HexDump(title string, b []byte)

func HexInteger

func HexInteger[T constraints.Integer](msg T) string

func HomeDir added in v0.0.56

func HomeDir() string

func Info

func Info(title string, msg ...any)

func IntegerToIP added in v0.0.56

func IntegerToIP(ip int64) string

func IsAix added in v0.0.56

func IsAix() 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

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

func IsDragonfly() 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 IsHurd added in v0.0.56

func IsHurd() bool

func IsIllumos added in v0.0.56

func IsIllumos() 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 IsNacl added in v0.0.56

func IsNacl() bool

func IsNetbsd added in v0.0.56

func IsNetbsd() bool

func IsOpenbsd added in v0.0.56

func IsOpenbsd() bool

func IsPlan9 added in v0.0.56

func IsPlan9() bool

func IsSolaris added in v0.0.56

func IsSolaris() bool

func IsTermux added in v0.0.56

func IsTermux() bool

func IsWasip1 added in v0.0.56

func IsWasip1() bool

func IsWindows

func IsWindows() bool

func IsZero added in v0.0.56

func IsZero(v reflect.Value) bool

func IsZos added in v0.0.56

func IsZos() 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(title string, msg ...any)

func JsonIndent added in v0.0.56

func JsonIndent(b []byte) string

func Lines added in v0.0.56

func Lines(x []byte) []string

func MarshalJSON added in v0.0.56

func MarshalJSON(v any) []byte

func MarshalJson

func MarshalJson(title string, msg any)

func MarshalJsonToFile added in v0.0.56

func MarshalJsonToFile(v any, name string)

func Message

func Message() string

func MoveFile added in v0.0.56

func MoveFile(src, dst string)

func ParseFloat added in v0.0.56

func ParseFloat(sizeStr string) (size float64)

func ParseInt added in v0.0.56

func ParseInt(s string) int64

func ParseUint added in v0.0.56

func ParseUint(s string) uint64

func RandomAny added in v0.0.56

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

func ReadFileToLines added in v0.0.56

func ReadFileToLines(path string) (lines []string)

func ReadLines added in v0.0.56

func ReadLines(fullPath string) ([]string, error)

func Reason

func Reason() (reason 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 RunDir added in v0.0.56

func RunDir() string

func SerialNumber added in v0.0.56

func SerialNumber(b string) string

func SetDebug

func SetDebug(debug bool)

func SlicesIndex added in v0.0.56

func SlicesIndex(slice any, item any) int

func SlicesInsert added in v0.0.56

func SlicesInsert(slice any, index int, value any) any

func SplitFileByLines added in v0.0.56

func SplitFileByLines(filePath string, size int)

func Struct

func Struct(msg any)

func SubStrRunes added in v0.0.56

func SubStrRunes(s string, length int) string

func Success

func Success(title string, msg ...any)

func SwapBytes added in v0.0.56

func SwapBytes(src []byte) (dst []byte)

func SwapBytes2HexString2 added in v0.0.56

func SwapBytes2HexString2(src HexString) (dst string)

func ToCamel added in v0.0.56

func ToCamel(data string, isCommit bool) string

func ToCamelToLower added in v0.0.56

func ToCamelToLower(s string, isCommit bool) string

func ToCamelUpper added in v0.0.56

func ToCamelUpper(s string, isCommit bool) string

func ToLines added in v0.0.56

func ToLines[T string | []byte | *os.File | *bytes.Buffer](data T) (lines []string)

func Todo added in v0.0.52

func Todo(body string)

func Trace

func Trace(title string, msg ...any)

func TrimExtension added in v0.0.56

func TrimExtension(path string) string

func TruncateLogFile

func TruncateLogFile()

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 Warning

func Warning(title string, 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 WriteLines added in v0.0.56

func WriteLines(lines []string, fullPath string) error

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 }

func NewBuffer added in v0.0.56

func NewBuffer[T Type](s 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 (*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) (xorStream []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) 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) []byte

func (*Buffer) InsertRune added in v0.0.56

func (b *Buffer) InsertRune(index int, r rune)

func (*Buffer) InsertString added in v0.0.56

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

func (*Buffer) InsertStringWithSplit added in v0.0.56

func (b *Buffer) InsertStringWithSplit(size int, insert string) string

func (*Buffer) LinesToString added in v0.0.56

func (b *Buffer) LinesToString(lines []string) string

func (*Buffer) MergeByte added in v0.0.56

func (b *Buffer) MergeByte(streams ...[]byte) []byte

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

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

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) ReplaceLine added in v0.0.71

func (b *Buffer) ReplaceLine(index int, line string) *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) SplitBytes added in v0.0.56

func (b *Buffer) SplitBytes(size int) (blocks [][]byte)

func (*Buffer) SplitString added in v0.0.56

func (b *Buffer) SplitString(size int) (blocks []string)

func (*Buffer) ToLines added in v0.0.56

func (b *Buffer) ToLines() (lines []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 HexDumpString added in v0.0.56

type HexDumpString string

type HexString added in v0.0.56

type HexString string

func SwapBytes2HexString added in v0.0.56

func SwapBytes2HexString(src []byte) (dst HexString)

type Pool added in v0.0.56

type Pool[T any] struct {
	// contains filtered or unexported fields
}

func NewPool added in v0.0.56

func NewPool[T any](fn func() T) *Pool[T]

func (*Pool[T]) Get added in v0.0.56

func (p *Pool[T]) Get() T

func (*Pool[T]) Put added in v0.0.56

func (p *Pool[T]) Put(v T)

type Type added in v0.0.56

type Type interface {
	string | HexString | HexDumpString | ~[]byte | ~*bytes.Buffer | *big.Int | *Buffer
}

Directories

Path Synopsis
close command
merge command
saf command

Jump to

Keyboard shortcuts

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