Documentation ¶
Index ¶
- Constants
- func ArgumentsCheck(argCount, min, max int) error
- func CheckAndExit(err error)
- func Clear()
- func CompressStr(str string) string
- func DeleteExtraSpace(s string) string
- func Displaylogo()
- func ErrorAssert(err error, assert string) bool
- func Execute(workDir, script string, args ...string) bool
- func ExitN(messageType string, message string, code int)
- func GetNodeIP() string
- func GetOSName() (string, error)
- func GetUsername() string
- func IsEmpty(path string) (bool, error)
- func IsNumeric(val interface{}) bool
- func IsSymLink(filepath string) (error, bool)
- func MergeSlice(s1 []string, s2 []string) []string
- func ParseAbsPath(filepath string, homeDir string) string
- func ParseConnect(connectStr string) (string, string, string)
- func ParseOriginalFilePath(filepath string) string
- func ParseRelPath(filepath string, homeDir string) string
- func PathExist(_path string) bool
- func PrintErr(err error)
- func PrintN(messageType string, message string)
- func Query(values, keys []string, ignoreCase bool) bool
- func Root() bool
- func SortKeys(m map[string]string) []string
- type SystemVersion
Constants ¶
const ( // CheckSymbol is the code for check symbol CheckSymbol = "\u2714 " // CrossSymbol is the code for check symbol CrossSymbol = "\u2716 " ExclamSymbol = "\u0021 " ArrowSymbol = "\u279c" DeleteSymbol = "\u2620" NoneSymbol = "\u2605" // Message type Info = "info" Err = "error" Warn = "warn" Inst = "install" Uinst = "uninstall" None = "none" Alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" )
Variables ¶
This section is empty.
Functions ¶
func ArgumentsCheck ¶
ArgumentsCheck check arguments count correctness
func CheckAndExit ¶
func CheckAndExit(err error)
func DeleteExtraSpace ¶
func Displaylogo ¶
func Displaylogo()
func GetNodeIP ¶
func GetNodeIP() string
GetNodeIP fetches node ip via command hostname. If it fails to get this, return empty string directly.
func GetOSName ¶
GetOSName gets data in /etc/os-release and gets OS name. For example, in a Ubuntu host, fetched data are like: root@i-8brpbc9t:~# cat /etc/os-release NAME="Ubuntu" VERSION="16.04.2 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.2 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial
func IsNumeric ¶
func IsNumeric(val interface{}) bool
IsNumeric is_numeric() Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. In PHP hexadecimal (e.g. 0xf4c3b00c) is not supported, but IsNumeric is supported.
func MergeSlice ¶
func ParseAbsPath ¶
return relative file path if filepath is absolute
func ParseConnect ¶
ParseConnect parse connect string, format is [user@]host[:port]
func ParseOriginalFilePath ¶
return the original file path if file is a symbol link
func ParseRelPath ¶
return absolute file path if filepath is relative
Types ¶
type SystemVersion ¶
type SystemVersion struct { Name string `json:"Name,omitempty"` // Arch type of underlying hardware Arch string `json:"Arch,omitempty"` // The time when this binary of daemon is built BuildTime string `json:"BuildTime,omitempty"` // Commit ID held by the latest commit operation GitCommit string `json:"GitCommit,omitempty"` // version of Go runtime GoVersion string `json:"GoVersion,omitempty"` // Operating system type of underlying system Os string `json:"Os,omitempty"` Version string `json:"Version,omitempty"` Banner string `json:"Banner,omitempty"` GitHub string `json:"GitHub,omitempty"` }
func Version ¶
func Version() (SystemVersion, error)