初始化项目

This commit is contained in:
皮蛋13361098506
2025-01-06 16:01:02 +08:00
commit 1b77f62820
575 changed files with 69193 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
package debugUtil
import (
"github.com/fatih/color"
)
var (
isDebug = false
code Code = Code_Bold
foregroundColor ForegroundColor = Foreground_Purple
backgroundColor BackgroundColor = BackgroundColor_Black
colorObj = color.New(foregroundColor, code)
)
// 设置DEBUG状态
// _isDebug是否是DEBUG
func SetDebug(_isDebug bool) {
isDebug = _isDebug
}
// 是否处于调试状态
func IsDebug() bool {
return isDebug
}
// 设置显示信息
func SetDisplayInfo(_code Code, _foregroundColor ForegroundColor, _backgroundColor BackgroundColor) {
code = _code
foregroundColor = _foregroundColor
backgroundColor = _backgroundColor
colorObj = color.New(foregroundColor, code)
}
// Print formats using the default formats for its operands and writes to standard output.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Print(a ...interface{}) {
if !isDebug {
return
}
_, _ = colorObj.Print(a...)
}
// Printf formats according to a format specifier and writes to standard output.
// It returns the number of bytes written and any write error encountered.
func Printf(format string, a ...interface{}) {
if !isDebug {
return
}
_, _ = colorObj.Printf(format, a...)
}
// Println formats using the default formats for its operands and writes to standard output.
// Spaces are always added between operands and a newline is appended.
// It returns the number of bytes written and any write error encountered.
func Println(a ...interface{}) {
if !isDebug {
return
}
_, _ = colorObj.Println(a...)
}

View File

@@ -0,0 +1,47 @@
package debugUtil
import "github.com/fatih/color"
// Code 显示代码
type Code = color.Attribute
const (
Code_Reset Code = color.Reset
Code_Bold Code = color.Bold
Code_Faint Code = color.Faint
Code_Italic Code = color.Italic
Code_Underline Code = color.Underline
Code_BlinkSlow Code = color.BlinkSlow
Code_BlinkRapid Code = color.BlinkRapid
Code_ReverseVideo Code = color.ReverseVideo
Code_Concealed Code = color.Concealed
Code_CrossedOut Code = color.CrossedOut
)
// ForegroundColor 前景色
type ForegroundColor = color.Attribute
const (
Foreground_Black ForegroundColor = color.FgBlack
Foreground_Red ForegroundColor = color.FgRed
Foreground_Green ForegroundColor = color.FgGreen
Foreground_Yellow ForegroundColor = color.FgYellow
Foreground_Blue ForegroundColor = color.FgBlue
Foreground_Purple ForegroundColor = color.FgMagenta
Foreground_Cyan ForegroundColor = color.FgCyan
Foreground_White ForegroundColor = color.FgWhite
)
// BackgroundColor 背景色
type BackgroundColor = color.Attribute
const (
BackgroundColor_Black = color.BgBlack
BackgroundColor_Red = color.BgRed
BackgroundColor_Green = color.BgGreen
BackgroundColor_Yellow = color.BgYellow
BackgroundColor_Blue = color.BgBlue
BackgroundColor_Purple = color.BgMagenta
BackgroundColor_Cyan = color.BgCyan
BackgroundColor_White = color.BgWhite
)

View File

@@ -0,0 +1,4 @@
/*
提供调试功能的助手包
*/
package debugUtil