utils

package
v0.0.0-...-350adb2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Blk Black text style
	Blk = "30"
	// Rd red text style
	Rd = "31"
	// Grn green text style
	Grn = "32"
	// Yel yellow text style
	Yel = "33"
	// Blu blue text style
	Blu = "34"
	// Mgn magenta text style
	Mgn = "35"
	// Cyn cyan text style
	Cyn = "36"
	// Wht white text style
	Wht = "37"
	// Gry grey text style
	Gry = "90"

	// BlkBg black background style
	BlkBg = "40"
	// RdBg red background style
	RdBg = "41"
	// GrnBg green background style
	GrnBg = "42"
	// YelBg yellow background style
	YelBg = "43"
	// BluBg blue background style
	BluBg = "44"
	// MgnBg magenta background style
	MgnBg = "45"
	// CynBg cyan background style
	CynBg = "46"
	// WhtBg white background style
	WhtBg = "47"

	// R reset emphasis style
	R = "0"
	// B bold emphasis style
	B = "1"
	// D dim emphasis style
	D = "2"
	// I italic emphasis style
	I = "3"
	// U underline emphasis style
	U = "4"
	// In inverse emphasis style
	In = "7"
	// H hidden emphasis style
	H = "8"
	// S strikeout emphasis style
	S = "9"
)

Color styles

Variables

This section is empty.

Functions

func Black

func Black(msg interface{}, styles ...string) string

func BlackBg

func BlackBg(msg interface{}, styles ...string) string

func Blue

func Blue(msg interface{}, styles ...string) string

func BlueBg

func BlueBg(msg interface{}, styles ...string) string

func Bold

func Bold(msg interface{}, styles ...string) string

func Cyan

func Cyan(msg interface{}, styles ...string) string

func CyanBg

func CyanBg(msg interface{}, styles ...string) string

func Dim

func Dim(msg interface{}, styles ...string) string

func Disable

func Disable()

func Enable

func Enable()

func Green

func Green(msg interface{}, styles ...string) string

func GreenBg

func GreenBg(msg interface{}, styles ...string) string

func Grey

func Grey(msg interface{}, styles ...string) string

func Hidden

func Hidden(msg interface{}, styles ...string) string

func Inverse

func Inverse(msg interface{}, styles ...string) string

func Italic

func Italic(msg interface{}, styles ...string) string

func Magenta

func Magenta(msg interface{}, styles ...string) string

func MagentaBg

func MagentaBg(msg interface{}, styles ...string) string

func Output

func Output() io.Writer

Output returns the output.

func Print

func Print(args ...interface{})

Print is analogous to `fmt.Print` with termial detection.

func Printf

func Printf(format string, args ...interface{})

Printf is analogous to `fmt.Printf` with termial detection.

func Println

func Println(args ...interface{})

Println is analogous to `fmt.Println` with termial detection.

func Red

func Red(msg interface{}, styles ...string) string

func RedBg

func RedBg(msg interface{}, styles ...string) string

func Reset

func Reset(msg interface{}, styles ...string) string

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output.

func Strikeout

func Strikeout(msg interface{}, styles ...string) string

func Table2Map

func Table2Map(tbl *lua.LTable) (map[string]interface{}, error)

Map maps the lua table to the given struct pointer.

func ToGoValue

func ToGoValue(lv lua.LValue, opt Option) interface{}

ToGoValue converts the given LValue to a Go object.

func ToUpperCamelCase

func ToUpperCamelCase(s string) string

ToUpperCamelCase is an Option.NameFunc that converts strings from snake case to upper camel case.

func Underline

func Underline(msg interface{}, styles ...string) string

func White

func White(msg interface{}, styles ...string) string

func WhiteBg

func WhiteBg(msg interface{}, styles ...string) string

func Yellow

func Yellow(msg interface{}, styles ...string) string

func YellowBg

func YellowBg(msg interface{}, styles ...string) string

Types

type Color

type Color struct {
	// contains filtered or unexported fields
}

func ColorNew

func ColorNew() (c *Color)

New creates a Color instance.

func (*Color) Black

func (c *Color) Black(msg interface{}, styles ...string) string

func (*Color) BlackBg

func (c *Color) BlackBg(msg interface{}, styles ...string) string

func (*Color) Blue

func (c *Color) Blue(msg interface{}, styles ...string) string

func (*Color) BlueBg

func (c *Color) BlueBg(msg interface{}, styles ...string) string

func (*Color) Bold

func (c *Color) Bold(msg interface{}, styles ...string) string

func (*Color) Cyan

func (c *Color) Cyan(msg interface{}, styles ...string) string

func (*Color) CyanBg

func (c *Color) CyanBg(msg interface{}, styles ...string) string

func (*Color) Dim

func (c *Color) Dim(msg interface{}, styles ...string) string

func (*Color) Disable

func (c *Color) Disable()

Disable disables the colors and styles.

func (*Color) Enable

func (c *Color) Enable()

Enable enables the colors and styles.

func (*Color) Green

func (c *Color) Green(msg interface{}, styles ...string) string

func (*Color) GreenBg

func (c *Color) GreenBg(msg interface{}, styles ...string) string

func (*Color) Grey

func (c *Color) Grey(msg interface{}, styles ...string) string

func (*Color) Hidden

func (c *Color) Hidden(msg interface{}, styles ...string) string

func (*Color) Inverse

func (c *Color) Inverse(msg interface{}, styles ...string) string

func (*Color) Italic

func (c *Color) Italic(msg interface{}, styles ...string) string

func (*Color) Magenta

func (c *Color) Magenta(msg interface{}, styles ...string) string

func (*Color) MagentaBg

func (c *Color) MagentaBg(msg interface{}, styles ...string) string

func (*Color) Output

func (c *Color) Output() io.Writer

Output returns the output.

func (*Color) Print

func (c *Color) Print(args ...interface{})

Print is analogous to `fmt.Print` with termial detection.

func (*Color) Printf

func (c *Color) Printf(format string, args ...interface{})

Printf is analogous to `fmt.Printf` with termial detection.

func (*Color) Println

func (c *Color) Println(args ...interface{})

Println is analogous to `fmt.Println` with termial detection.

func (*Color) Red

func (c *Color) Red(msg interface{}, styles ...string) string

func (*Color) RedBg

func (c *Color) RedBg(msg interface{}, styles ...string) string

func (*Color) Reset

func (c *Color) Reset(msg interface{}, styles ...string) string

func (*Color) SetOutput

func (c *Color) SetOutput(w io.Writer)

SetOutput sets the output.

func (*Color) Strikeout

func (c *Color) Strikeout(msg interface{}, styles ...string) string

func (*Color) Underline

func (c *Color) Underline(msg interface{}, styles ...string) string

func (*Color) White

func (c *Color) White(msg interface{}, styles ...string) string

func (*Color) WhiteBg

func (c *Color) WhiteBg(msg interface{}, styles ...string) string

func (*Color) Yellow

func (c *Color) Yellow(msg interface{}, styles ...string) string

func (*Color) YellowBg

func (c *Color) YellowBg(msg interface{}, styles ...string) string

type Option

type Option struct {
	// Function to convert a lua table key to Go's one. This defaults to "ToUpperCamelCase".
	NameFunc func(string) string

	// Returns error if unused keys exist.
	ErrorUnused bool

	// A struct tag name for lua table keys . This defaults to "gluamapper"
	TagName string
}

Option is a configuration that is used to create a new mapper.

type SizeWaitGroup

type SizeWaitGroup struct {
	Size int
	// contains filtered or unexported fields
}

SizeWaitGroup 用于控制goroutine的并发数量

func NewSizeWaitGroup

func NewSizeWaitGroup(size int) SizeWaitGroup

创建一个固定大小的拥塞队列

func (*SizeWaitGroup) Add

func (swg *SizeWaitGroup) Add()

Add 队列+1

func (*SizeWaitGroup) Done

func (swg *SizeWaitGroup) Done()

Done 队列-1

func (*SizeWaitGroup) EnterWithContext

func (swg *SizeWaitGroup) EnterWithContext(ctx context.Context)

func (*SizeWaitGroup) Wait

func (swg *SizeWaitGroup) Wait()

Wait 阻塞等待队列全部完成

type Switch

type Switch struct {
	// contains filtered or unexported fields
}

Switch 用于模拟开关行为的事件结构

func NewSwitch

func NewSwitch() *Switch

NewSwitch 返回一个新的开关事件

func (*Switch) Done

func (s *Switch) Done() <-chan struct{}

Done 事件触发

func (*Switch) HasOpend

func (s *Switch) HasOpend() bool

HasOpend 是否以开启

func (*Switch) Open

func (s *Switch) Open() bool

Open 开启

type UploadFile

type UploadFile struct {
	File   multipart.File
	Header *multipart.FileHeader
	// contains filtered or unexported fields
}

func NewUploadFile

func NewUploadFile(file multipart.File, header *multipart.FileHeader) *UploadFile

func (*UploadFile) FileName

func (f *UploadFile) FileName() string

FileName get upload file client-local name

func (*UploadFile) GetFileExt

func (f *UploadFile) GetFileExt() string

GetFileExt get upload file extensions

func (*UploadFile) ReadBytes

func (f *UploadFile) ReadBytes() []byte

ReadBytes Bytes returns a slice of byte hoding the UploadFile.File special: if you read bytes, it's will cause empty data in UploadFile.File, so you use SaveFile will no any data to save

func (*UploadFile) SaveFile

func (f *UploadFile) SaveFile(fileName string) (size int64, err error)

SaveFile save file in server-local with filename special: if you SaveFile, it's will cause empty data when use ReadBytes

func (*UploadFile) Size

func (f *UploadFile) Size() int64

Size get upload file size

Jump to

Keyboard shortcuts

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