Documentation ¶
Overview ¶
common is a package that summarizes the common processing of lssh package.
Index ¶
- Constants
- func Contains(list interface{}, elem interface{}) bool
- func GetDefaultConfigPath() (path string)
- func GetFilesBase64(paths []string, iscompress int) (result string, err error)
- func GetFullPath(path string) (fullPath string)
- func GetIdFromName(file string, name string) (id uint32, err error)
- func GetMaxLength(list []string) (MaxLength 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 IsDirPath(path string) (isDir bool)
- func IsExist(filename string) bool
- func MapMerge(m ...map[string]interface{}) map[string]interface{}
- 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 ParseHostPath(value string) (host []string, path string)
- func ParseNFSForwardPortPath(value string) (port, path string, err error)
- func RandomString(n int) string
- func StringCompression(mode int, data []byte) (result []byte, err error)
- func StructToMap(val interface{}) (mapVal map[string]interface{}, ok bool)
- func WalkDir(dir string) (files []string, err error)
Constants ¶
const ( ARCHIVE_NONE = iota ARCHIVE_GZIP )
enum
Variables ¶
This section is empty.
Functions ¶
func GetDefaultConfigPath ¶ added in v0.6.8
func GetDefaultConfigPath() (path string)
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.0
GetUserName return user name from /etc/passwd and uid.
func GetMaxLength ¶
GetMaxLength returns a max length of list. Length is byte length.
func GetNameFromId ¶ added in v0.6.0
GetUserName return user name from /etc/passwd and uid.
func GetOrderNumber ¶ added in v0.5.5
Get order num in array
func GetPassPhrase ¶ added in v0.6.0
GetPassPhrase gets the passphrase from virtual terminal input and returns the result. Works only on UNIX-based OS.
func GetUniqueSlice ¶ added in v0.6.0
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.5.6
NewSHA1Hash generates a new SHA1 hash based on a random number of characters.
func ParseArgs ¶ added in v0.6.0
ParseArgs return os.Args parse short options (ex.) [-la] => [-l,-a] )
TODO(blacknon): Migrate to github.com/urfave/cli version 1.22.
func ParseForwardPort ¶ added in v0.6.0
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 ParseHostPath ¶ added in v0.6.7
ParseHostPath return host and path, from host:/path/to/dir/file.
func ParseNFSForwardPortPath ¶ added in v0.6.12
ParseNFSForwardPortPath
func RandomString ¶ added in v0.5.6
RandomString generates a random string of n length
func StringCompression ¶ added in v0.6.7
StringCompression compresses bytes in the specified mode.
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.