sftpgo

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 12 Imported by: 0

README

sftpgo

SFTP wrapper for Golang

Install

go get github.com/innotechdevops/sftpgo

How to use

func New() sftpgo.SftpClient {
	config := sftpgo.Config{
		Host:     configuration.Config.Sftp.Report.Host,
		Username: configuration.Config.Sftp.Report.Username,
		Password: configuration.Config.Sftp.Report.Password,
		Port:     configuration.Config.Sftp.Report.Port,
	}

	csftp, err := sftpgo.NewClient(&config)
	if err != nil {
		log.Panic("New SFTP client", err.Error())
	}
	return csftp
}

client := New()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host, Username, Password string
	Port                     int
	SSHTrustedKey            string
}

type SftpClient

type SftpClient interface {
	OpenFile(remoteFile string) (*sftp.File, error)
	PutFile(localFile, remoteFile string) (err error)
	PutString(text, remoteFile string) (err error)
	GetRecords(remoteFile string, onReader func(file *sftp.File) ([][]string, error)) ([][]string, error)
	Files(remoteDir string) []os.FileInfo
	WalkFiles(remoteDir string) ([]string, error)
	MoveFile(sourcePath string, destPath string) error
	RemoveFile(dirPath string) error
	Close() error
	ConnectionLostHandler(err error)
	EnsureDirExists(filePath string) error
}

func NewClient

func NewClient(conn SftpConn) (SftpClient, error)

NewClient Create a new SFTP connection by given parameters

type SftpConn added in v1.2.0

type SftpConn interface {
	Connect() (client *sftp.Client, err error)
}

func NewSftpConn added in v1.2.0

func NewSftpConn(c *Config) SftpConn

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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