common

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 11 Imported by: 15

Documentation

Index

Constants

View Source
const (
	DefaultStringZeroValue = ""
	DefaultIntZeroValue    = 0
	DefaultSSHTimeout      = 10 * time.Second
	DefaultSSHPortNum      = 22
	DefaultSSHUserName     = "root"
	DefaultSSHUserPass     = "shit"
	DefaultByteBufferSize  = 1024 * 1024 // 1MB

)

Variables

This section is empty.

Functions

func ConvertInterfaceToMapInterfaceInterface

func ConvertInterfaceToMapInterfaceInterface(in interface{}) (map[interface{}]interface{}, error)

func ConvertInterfaceToSliceInterface

func ConvertInterfaceToSliceInterface(in interface{}) ([]interface{}, error)

func ElementInSlice

func ElementInSlice(e interface{}, s interface{}) (bool, error)

func KeyInMap

func KeyInMap(k interface{}, m interface{}) (bool, error)

func PathExists

func PathExists(in ...interface{}) (bool, error)

func PathExistsLocal

func PathExistsLocal(path string) (bool, error)

func PathExistsRemote

func PathExistsRemote(path string, client *sftp.Client) (bool, error)

func TrimSpaceOfStructString

func TrimSpaceOfStructString(in interface{}) error

func ValueInMap

func ValueInMap(v interface{}, m interface{}) (bool, error)

Types

type CloseConn

type CloseConn interface {
	CloseConn()
}

type MyConn

type MyConn struct {
	HostIp   string
	PortNum  int
	UserName string
	UserPass string
}

func NewMyConn

func NewMyConn(hostIp string, portNum int, userName string, userPass string) (conn *MyConn)

func NewMyConnWithDefaultValue

func NewMyConnWithDefaultValue(hostIp string) (conn *MyConn)

type MySSHConn

type MySSHConn struct {
	MyConn
	SSHClient  *ssh.Client
	SSHSession *ssh.Session
}

func NewMySSHConn

func NewMySSHConn(hostIp string, in ...interface{}) (sshConn *MySSHConn, err error)

NewMySSHConn returns *MySSHConn and error, first argument is mandatory which presents host ip, and the 3 flowing optional arguments which should be in exact order of port number, user name and user password

func NewMySSHConnWithDefaultValue

func NewMySSHConnWithDefaultValue(hostIp string) (sshConn *MySSHConn, err error)

func (*MySSHConn) CloseConn

func (conn *MySSHConn) CloseConn() error

func (*MySSHConn) ExecuteCommand

func (conn *MySSHConn) ExecuteCommand(cmd string) (result int, stdOut string, stdErr string, err error)

func (*MySSHConn) GetHostName

func (conn *MySSHConn) GetHostName() (hostName string, err error)

type MySftpConn

type MySftpConn struct {
	MySSHConn
	SftpClient *sftp.Client
}

func NewMySftpConn

func NewMySftpConn(hostIp string, in ...interface{}) (sftpConn *MySftpConn, err error)

NewMySftpConn returns *MySftpConn and error, first argument is mandatory which presents host ip, and the 3 flowing optional arguments which should be in exact order of port number, user name and user password

func NewMySftpConnWithDefaultValue

func NewMySftpConnWithDefaultValue(hostIp string) (sftpConn *MySftpConn, err error)

func (*MySftpConn) CloseConn

func (conn *MySftpConn) CloseConn() (err error)

func (*MySftpConn) CopyFile

func (conn *MySftpConn) CopyFile(fileSource io.Reader, fileDest io.Writer, bufferSize int) (err error)

func (*MySftpConn) CopyFileListFromRemote

func (conn *MySftpConn) CopyFileListFromRemote(fileListSource []string, FileDirDest string) (err error)

func (*MySftpConn) CopyFileListFromRemoteWithNewName

func (conn *MySftpConn) CopyFileListFromRemoteWithNewName(fileListSource []string, FileListDest []string) (err error)

func (*MySftpConn) CopySingleFileFromRemote

func (conn *MySftpConn) CopySingleFileFromRemote(fileNameSource string, fileNameDest string) (err error)

func (*MySftpConn) CopySingleFileToRemote

func (conn *MySftpConn) CopySingleFileToRemote(fileNameSource string, fileNameDest string) (err error)

Jump to

Keyboard shortcuts

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