utils

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PREFIX_COBRA_COMMAND_ERROR = "Error:\n"
)
View Source
const (
	REGEX_IP = `^(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})`
)

Variables

View Source
var (
	NoArgs            = cli.NoArgs
	RequiresMinArgs   = cli.RequiresMinArgs
	RequiresMaxArgs   = cli.RequiresMaxArgs
	RequiresRangeArgs = cli.RequiresRangeArgs
	ExactArgs         = cli.ExactArgs

	ShowHelp = command.ShowHelp
)

Functions

func AbsPath added in v0.1.0

func AbsPath(path string) string

func All2Str

func All2Str(v interface{}) (value string, ok bool)

func Atoa

func Atoa(v interface{}) string

convert all to string

func CheckMountPoint

func CheckMountPoint(mountPoint string) error

func Choose

func Choose(ok bool, first, second string) string

func DeepCopy

func DeepCopy(src map[string]interface{}) map[string]interface{}

func Diff

func Diff(s1 string, s2 string) string

func EncryptFile

func EncryptFile(srcfile, dstfile, secret string) error

func ExecShell

func ExecShell(format string, a ...interface{}) (string, error)

func GetCurrentHomeDir added in v0.1.0

func GetCurrentHomeDir() string

func GetCurrentUser

func GetCurrentUser() string

func GetFilePermissions added in v0.1.0

func GetFilePermissions(path string) int

func IsBool

func IsBool(v interface{}) bool

func IsFunc

func IsFunc(v interface{}) bool

func IsInt

func IsInt(v interface{}) bool

func IsInt64

func IsInt64(v interface{}) bool

func IsString

func IsString(v interface{}) bool

func IsStringAnyMap

func IsStringAnyMap(v interface{}) bool

func IsTrueStr added in v0.0.23

func IsTrueStr(s string) bool

func IsValidAddress added in v0.2.0

func IsValidAddress(address string) bool

func Locate

func Locate(s []string) map[string]int

func MD5Sum

func MD5Sum(data string) string

func Min

func Min(nums ...int) int

func NewCommand

func NewCommand(format string, a ...interface{}) *exec.Cmd

func PathExist

func PathExist(path string) bool

func RandFilename

func RandFilename(dir string) string

func RandString

func RandString(n int) string

func ReadFile

func ReadFile(filename string) (string, error)

func SetErr added in v0.1.0

func SetErr(cmd *cobra.Command, writer io.Writer)

func SetFlagErrorFunc

func SetFlagErrorFunc(cmd *cobra.Command)

func SetHelpTemplate

func SetHelpTemplate(cmd *cobra.Command)

func SetUsageTemplate

func SetUsageTemplate(cmd *cobra.Command)

func Slice2Map

func Slice2Map(s []string) map[string]bool

func Str2Bool

func Str2Bool(s string) (bool, bool)

func Str2Int

func Str2Int(s string) (int, bool)

func TrimSuffixRepeat added in v0.1.0

func TrimSuffixRepeat(s, suffix string) string

func Type

func Type(v interface{}) string

func WriteFile

func WriteFile(filename, data string, mode int) error

Types

type PromptError

type PromptError struct {
	Err    error
	Prompt string
}

func (PromptError) Error

func (e PromptError) Error() string

type SafeMap

type SafeMap struct {
	sync.RWMutex
	Map map[string]interface{}
	// contains filtered or unexported fields
}

func NewSafeMap

func NewSafeMap() *SafeMap

func (*SafeMap) Get

func (m *SafeMap) Get(key string) interface{}

func (*SafeMap) Set

func (m *SafeMap) Set(key string, value interface{})

func (*SafeMap) TX added in v0.1.0

func (m *SafeMap) TX(callback func(m *SafeMap) error) error

type VariantName added in v0.1.0

type VariantName struct {
	Name                string
	CompressName        string
	LocalCompressName   string
	EncryptCompressName string
}

func NewVariantName added in v0.1.0

func NewVariantName(name string) VariantName

Jump to

Keyboard shortcuts

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