Documentation ¶
Index ¶
- Variables
- func CheckAndCreateDir(path string) error
- func CmdExec(args string) (string, error)
- func CmdRunWithTimeout(cmd *exec.Cmd, timeout time.Duration) (bool, error)
- func CopyFile(source, target string) error
- func CreateFileHash(sourceFile, hashfile string) error
- func CreateHashString(source string) (hashstr string, err error)
- func CreateHostID() (string, error)
- func CreateVersionByTime() string
- func Deweight(data *[]string)
- func DirIsEmpty(dir string) bool
- func DiskUsage(path string) (tatol, free uint64)
- func Exec(ctx context.Context, f func() error, wait time.Duration) error
- func FileExists(filename string) (bool, error)
- func FileExistsWithSuffix(pathDir, suffix string) bool
- func GetCurrentDir() string
- func GetDirList(dirpath string, level int) ([]string, error)
- func GetDirNameList(dirpath string, level int) ([]string, error)
- func GetDirSize(path string) float64
- func GetDirSizeByCmd(path string) float64
- func GetFileList(dirpath string, level int) ([]string, error)
- func GetFileSize(path string) int64
- func GetIDFromKey(key string) string
- func GetParentDirectory(dirctory string) string
- func IntermittentExec(ctx context.Context, f func(), t time.Duration)
- func IsHaveFile(path string) bool
- func LocalIP() (net.IP, error)
- func MergeDir(fromdir, todir string) error
- func NewUUID() string
- func OpenOrCreateFile(filename string) (*os.File, error)
- func ProfilerSetup(r *chi.Mux)
- func ReadHostID(filePath string) (string, error)
- func RemoveSpaces(sources []string) (re []string)
- func Rename(old, new string) error
- func SearchFile(pathDir, name string, level int) bool
- func SearchFileBody(filename, searchStr string) bool
- func SendNoBlocking(m []byte, ch chan []byte)
- func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
- func ToByte(v string) []byte
- func ToString(b []byte) string
- func Translation(english string) string
- func Unzip(archive, target string) error
- func Zip(source, target string) error
- type PipeCommand
- type SSHClient
- type StdType
Constants ¶
This section is empty.
Variables ¶
var StatefulServiceType = "StatefulServiceType"
StatefulServiceType 有状态应用
var StatelessServiceType = "StatelessServiceType"
StatelessServiceType 无状态应用
Functions ¶
func CheckAndCreateDir ¶
CheckAndCreateDir check and create dir
func CmdRunWithTimeout ¶
CmdRunWithTimeout exec cmd with timeout
func CopyFile ¶
CopyFile copy source file to target direct io read and write file Keep the permissions user and group
func CreateFileHash ¶
CreateFileHash compute sourcefile hash and write hashfile
func CreateHashString ¶
CreateHashString create hash string
func CreateVersionByTime ¶
func CreateVersionByTime() string
CreateVersionByTime create version number
func FileExistsWithSuffix ¶
FileExistsWithSuffix 指定目录是否含有指定后缀的文件
func GetDirList ¶
GetDirList get all lower level dir
func GetDirNameList ¶
GetDirNameList get all lower level dir
func GetDirSizeByCmd ¶
GetDirSizeByCmd get dir sizes by du command return kb
func GetParentDirectory ¶
GetParentDirectory GetParentDirectory
func IntermittentExec ¶
IntermittentExec 间歇性执行
func OpenOrCreateFile ¶
OpenOrCreateFile open or create file
func ReadHostID ¶
ReadHostID 读取当前机器ID ID是节点的唯一标识,acp_node将把ID与机器信息的绑定关系维护于etcd中
func SearchFile ¶
SearchFile 搜索指定目录是否有指定文件,指定搜索目录层数,-1为全目录搜索
func SearchFileBody ¶
SearchFileBody 搜索文件中是否含有指定字符串
func StdCopy ¶
StdCopy is a modified version of io.Copy.
StdCopy will demultiplex `src`, assuming that it contains two streams, previously multiplexed together using a StdWriter instance. As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.
StdCopy will read until it hits EOF on `src`. It will then return a nil error. In other words: if `err` is non nil, it indicates a real underlying error.
`written` will hold the total number of bytes written to `dstout` and `dsterr`.
func Translation ¶
Translation Translation English to Chinese
Types ¶
type PipeCommand ¶
type PipeCommand struct {
// contains filtered or unexported fields
}
PipeCommand PipeCommand
func NewPipeCommand ¶
func NewPipeCommand(stack ...*exec.Cmd) (*PipeCommand, error)
NewPipeCommand new pipe commands
func (*PipeCommand) GetFinalStderr ¶
func (p *PipeCommand) GetFinalStderr() io.Reader
GetFinalStderr get final command stderr reader
func (*PipeCommand) GetFinalStdout ¶
func (p *PipeCommand) GetFinalStdout() io.Reader
GetFinalStdout get final command stdout reader
type SSHClient ¶
type SSHClient struct { IP string Port int User string Password string Method string Key string Stdout, Stderr io.Writer Cmd string }
SSHClient ssh client
func NewSSHClient ¶
NewSSHClient new ssh client
type StdType ¶
type StdType byte
StdType is the type of standard stream a writer can multiplex to.
const ( // Stdin represents standard input stream type. Stdin StdType = iota // Stdout represents standard output stream type. Stdout // Stderr represents standard error steam type. Stderr // Systemerr represents errors originating from the system that make it // into the the multiplexed stream. Systemerr )