format

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopLeft   = "╭"
	TopMiddle = "┬"
	TopRight  = "╮"

	MiddleLeft   = "├"
	MiddleCenter = "┼"
	MiddleRight  = "┤"

	HLine = "─"
	VLine = "│"

	BottomLeft   = "╰"
	BottomMiddle = "┴"
	BottomRight  = "╯"
)

Variables

View Source
var (
	CallerList = []*funcCaller{}
	MainStart  = time.Now()
)
View Source
var (
	Info    = infoRender
	Warning = warningRender
	Fatal   = fatalRender
	Success = successRender
)
View Source
var (
	VariableList = []Variable{}
	PrintBuffer  = strings.Builder{}
	TitleColor   = "\033[1;36m"
	// TODO ColorList
	ColorList      = []string{}
	TableMaxLength = 28

	TopNotationList    = []string{"╭", "─", "┬", "╮\n"}
	MiddleNotationList = []string{"├", "─", "┼", "┤\n"}
	BottomNotationList = []string{"╰", "─", "┴", "╯\n"}
)
View Source
var (
	StringBuilder = strings.Builder{}
)

Functions

func BlockMessage

func BlockMessage(title string, content []string)

func Blue added in v0.0.2

func Blue(s string)

func BlueBg added in v0.0.2

func BlueBg(s string)

func BoxError

func BoxError(_title string, _content string)

func BoxInfo

func BoxInfo(_title string, _content string)

func BoxMessage

func BoxMessage(_title string, _content string)

func BoxSuccess

func BoxSuccess(_title string, _content string)

func BoxWarning

func BoxWarning(_title string, _content string)

func BytesToString

func BytesToString(b []byte) string

BytesToString converts bytes to a string without memory allocation. NOTE: The given bytes MUST NOT be modified since they share the same backing array with the returned string.

func CallCost

func CallCost() *funcCaller

func Check

func Check(err error)

func CheckVar

func CheckVar(name string, a any)

func ColorTextLength

func ColorTextLength(ctx string) int

func ContentLeftAlign

func ContentLeftAlign(ctx string, length int) string

func DrawBlockLine

func DrawBlockLine(length int, s1 string, s2 string, s3 string)

func DrawBottom

func DrawBottom(lengthList []int)

func DrawCallerTable added in v0.0.2

func DrawCallerTable(titleList []string, lengthList []int)

func DrawLine

func DrawLine(__type__ int, lengthList []int)

func DrawMiddle

func DrawMiddle(lengthList []int)

func DrawTableContent

func DrawTableContent(content []string, length []int)

func DrawTableLine

func DrawTableLine(length []int, left string, seq string, split string, right string)

func DrawTop

func DrawTop(lengthList []int)

这样其实还是有意义的我觉得

func DrawTopContent

func DrawTopContent(titleList []string, lengthList []int)

func ExecutePath

func ExecutePath() string

func Green added in v0.0.2

func Green(s string)

func GreenBg added in v0.0.2

func GreenBg(s string)

func LogFormat added in v0.0.2

func LogFormat(title, content string)

time file:line Error title Error content

func MaxLength

func MaxLength(s []string) int

func MiddleAlign

func MiddleAlign(ctx string, length int) string

func Must

func Must(err error)

func PrintTimerLogs

func PrintTimerLogs()

func PrintVariables

func PrintVariables()

func Recover

func Recover()

func Red added in v0.0.2

func Red(s string)

func RedBg added in v0.0.2

func RedBg(s string)

func Release added in v0.0.2

func Release()

func Render

func Render(ctx string, rgb string) string

TODO Render more color

func SetOutput added in v0.0.2

func SetOutput(w io.Writer)

func SetOutputFile added in v0.0.2

func SetOutputFile(src string)

func SetOutputTemp added in v0.0.2

func SetOutputTemp()

func StringLen

func StringLen(s string) int

StringLen return the width of string, support unicode abcd --> 4 你好 --> 4

func StringToBytes

func StringToBytes(s string) []byte

reference : https://github.com/josestg/zerocast StringToBytes converts a string to a byte slice without memory allocation. NOTE: The returned byte slice MUST NOT be modified since it shares the same backing array with the given string.

func TableMessage

func TableMessage(_title []string, _content [][]string)

func TimerStart

func TimerStart() *timer

func Timestamp

func Timestamp() string

func TitleMiddleAlign

func TitleMiddleAlign(ctx string, length int) string

func UnixTime

func UnixTime() int64

func Yellow added in v0.0.2

func Yellow(s string)

func YellowBg added in v0.0.2

func YellowBg(s string)

Types

type Variable

type Variable struct {
	Name string

	Addr string
	// contains filtered or unexported fields
}

TODO Variable size

Jump to

Keyboard shortcuts

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