sftp

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sftp provides an SFTP client that wraps SSH connection + SFTP session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host config.Host
	// contains filtered or unexported fields
}

Client holds an SSH connection and an SFTP session on top of it.

func Connect

func Connect(ctx context.Context, host config.Host) (*Client, error)

Connect dials SSH and opens an SFTP subsystem session.

func (*Client) Close

func (c *Client) Close() error

Close closes both the SFTP session and SSH connection.

func (*Client) DeleteFile

func (c *Client) DeleteFile(remotePath string) error

DeleteFile removes a file on the remote host.

func (*Client) DownloadFile

func (c *Client) DownloadFile(remotePath, localPath string) error

DownloadFile copies a remote file to a local path.

func (*Client) ReadFile

func (c *Client) ReadFile(remotePath string) ([]byte, error)

ReadFile reads the full content of a remote file.

func (*Client) Stat

func (c *Client) Stat(remotePath string) (os.FileInfo, error)

Stat returns file info for a remote path.

func (*Client) UploadFile

func (c *Client) UploadFile(localPath, remotePath string) error

UploadFile copies a local file to a remote path.

func (*Client) WalkFiles

func (c *Client) WalkFiles(remoteRoot string, fn func(path string) error) error

WalkFiles calls fn for every regular file under remoteRoot, recursively. Unreadable entries are skipped silently.

func (*Client) WriteFile

func (c *Client) WriteFile(remotePath string, data []byte) error

WriteFile writes data to a remote path, creating parent directories as needed.

Jump to

Keyboard shortcuts

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