util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation(action string) bool

askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Typically, you should use fmt to print out a question before calling askForConfirmation. E.g. fmt.Println("WARNING: Are you sure? (yes/no)")

func CheckErr

func CheckErr(err error)

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func GreenColor

func GreenColor(s string) string

func Int64toString

func Int64toString(i int64) string

func InttoString

func InttoString(i int) string

func IsTerminal

func IsTerminal(f *os.File) bool

func PrintifyDockerfile added in v0.0.2

func PrintifyDockerfile(writer io.Writer, dockerfile []byte)

func PrintifyJSON added in v0.0.2

func PrintifyJSON(writer io.Writer, v interface{}) error

func RedColor

func RedColor(s string) string

func ReturnMsg

func ReturnMsg(ctx *gin.Context, code int, data interface{}, msg string)

func SliceDelOne

func SliceDelOne(a string, b []string) []string

func SlicetoString

func SlicetoString(s []string) string

func SnowId

func SnowId() (int64, error)

func StdRun added in v0.0.2

func StdRun(args ...string)

func StringtoInt64

func StringtoInt64(s string) int64

func StringtoSlice

func StringtoSlice(s string) []string

func StructToSlice

func StructToSlice(f interface{}) []string

func WriteToFile

func WriteToFile(filename string, v interface{}, marshal func(v interface{}) ([]byte, error)) error

func YellowColor

func YellowColor(s string) string

Types

type IDMgr

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

func NewIdMgr

func NewIdMgr(node uint16) (*IDMgr, error)

func (*IDMgr) ID

func (c *IDMgr) ID() int64

type IGenID

type IGenID interface {
	ID() int64
}

type Res

type Res struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

Jump to

Keyboard shortcuts

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