Documentation ¶
Overview ¶
Package common is a package that summarizes the common processing of bssh package. nolint:goerr113
Index ¶
- func CheckHelpFlag(c *cli.Context)
- func Contains(s []string, e string) bool
- func CreateRateLimit(r io.Reader) io.Reader
- func ExpandHomeDir(f string) string
- func GetFilesBase64(paths []string) (string, error)
- func GetFullPath(path string) (fullPath string)
- func GetIDFromName(file string, name string) (id uint32, err error)
- func GetMaxLength(list []string) int
- func GetNameFromID(file string, id uint32) (name string, err error)
- func GetOrderNumber(value string, array []string) int
- func GetPassPhrase(msg string) (input string, err error)
- func GetUniqueSlice(data []string) (result []string)
- func IsExist(filename string) bool
- func IsHidden(basedir, path string) bool
- func MapReduce(map1, map2 map[string]interface{}) map[string]interface{}
- func MapToStruct(mapVal map[string]interface{}, val interface{}) (ok bool)
- func NewSHA1Hash(n ...int) string
- func ParseArgs(options []cli.Flag, args []string) []string
- func ParseForwardPort(value string) (local, remote string, err error)
- func RandomString(n int) string
- func StructToMap(val interface{}) (mapVal map[string]interface{}, ok bool)
- func WalkDir(dir string) (files []string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckHelpFlag ¶ added in v0.6.13
CheckHelpFlag checks the help flag then show app help and exit.
func ExpandHomeDir ¶ added in v0.6.13
ExpandHomeDir expands the ~ in the path if it is available.
func GetFilesBase64 ¶ added in v0.5.1
GetFilesBase64 returns a base64 encoded string of file content of paths.
func GetFullPath ¶
GetFullPath returns a fullpath of path. Expands `~` to user directory ($HOME environment variable).
func GetIDFromName ¶ added in v0.6.13
GetIDFromName return user name from /etc/passwd and uid.
func GetMaxLength ¶
GetMaxLength returns a max byte length of list.
func GetNameFromID ¶ added in v0.6.13
GetNameFromID return user name from /etc/passwd and uid.
func GetOrderNumber ¶ added in v0.6.13
GetOrderNumber get order num in array.
func GetPassPhrase ¶ added in v0.6.13
GetPassPhrase gets the passphrase from virtual terminal input and returns the result. Works only on UNIX-based OS.
func GetUniqueSlice ¶ added in v0.6.13
GetUniqueSlice return slice, removes duplicate values from data(slice).
func MapReduce ¶
MapReduce sets map1 value to map2 if map1 and map2 have same key, and value of map2 is zero value. Available interface type is string or []string or bool.
WARN: This function returns a map, but updates value of map2 argument too.
func MapToStruct ¶
MapToStruct sets value of mapVal to public field of val struct. Raises panic if mapVal has keys of private field of val struct or field that val struct doesn't have.
WARN: ok value is not used. Always returns false.
func NewSHA1Hash ¶ added in v0.6.13
NewSHA1Hash generates a new SHA1 hash based on a random number of characters.
func ParseArgs ¶ added in v0.6.13
ParseArgs return os.Args parse short options (ex.) [-la] => [-l,-a] )
TDXX(blacknon): Migrate to github.com/urfave/cli version 1.22.
func ParseForwardPort ¶ added in v0.6.13
ParseForwardPort return forward address and port from string.
ex.)
- `localhost:8000:localhost:18000` => local: "localhost:8000", remote: "localhost:18000"
- `8080:localhost:18080` => local: "localhost:8080", remote: "localhost:18080"
- `localhost:2222:12222` => local: "localhost:2222", remote: "localhost:12222"
func RandomString ¶ added in v0.6.13
RandomString generates a random string of n length.
func StructToMap ¶
StructToMap returns a map that converted struct to map. Keys of map are set from public field of struct.
WARN: ok value is not used. Always returns false.
Types ¶
This section is empty.