Documentation
¶
Index ¶
- Constants
- func FormatSize(bytes int64) string
- type Client
- func (c *Client) Chdir(dir string) error
- func (c *Client) ClearDirCache()
- func (c *Client) Close() error
- func (c *Client) Download(remotePath, localPath string) error
- func (c *Client) DownloadDir(remoteDir, localDir string, opts *DownloadOptions) (int, error)
- func (c *Client) DownloadGlob(pattern, localPath string, opts *DownloadOptions) (int, error)
- func (c *Client) DownloadSources(remoteSources []string, localDir string, opts *DownloadOptions) (int, error)
- func (c *Client) DownloadWithProgress(remotePath, localPath string, globalBar *progressbar.ProgressBar) error
- func (c *Client) ExecuteRemote(command string, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Client) GetLocalwd() string
- func (c *Client) Getwd() string
- func (c *Client) List(dir string) ([]os.FileInfo, error)
- func (c *Client) ListCompletion(prefix string) []string
- func (c *Client) LocalChdir(dir string) error
- func (c *Client) LocalList(dir string) ([]os.FileInfo, error)
- func (c *Client) LocalMkdir(dir string) error
- func (c *Client) Mkdir(dir string) error
- func (c *Client) Remove(remotePath string) error
- func (c *Client) RemoveDir(remotePath string) error
- func (c *Client) Rename(oldPath, newPath string) error
- func (c *Client) ResolveLocalPath(p string) string
- func (c *Client) ResolveRemotePath(p string) string
- func (c *Client) Stat(remotePath string) (os.FileInfo, error)
- func (c *Client) Upload(localPath, remotePath string) error
- func (c *Client) UploadDir(localDir, remoteDir string, opts *UploadOptions) (int, error)
- func (c *Client) UploadGlob(pattern, remotePath string, opts *UploadOptions) (int, error)
- func (c *Client) UploadSources(localSources []string, remoteDir string, opts *UploadOptions) (int, error)
- func (c *Client) UploadWithProgress(localPath, remotePath string, globalBar *progressbar.ProgressBar) error
- type DownloadOptions
- type TransferOptions
- type UploadOptions
Constants ¶
const ( // BufferSize 传输缓冲区大小 (512KB) BufferSize = 512 * 1024 // MaxConcurrentTransfers 最大并发传输数 MaxConcurrentTransfers = 4 // DirCacheTimeout 目录列表缓存超时时间 DirCacheTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func FormatSize ¶ added in v0.10.1
FormatSize formats bytes into human-readable form (binary units, 1 decimal).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client SFTP 客户端封装
func NewClient ¶
func NewClient(addr string, config *ssh.ClientConfig) (*Client, error)
NewClient 创建 SFTP 客户端
func (*Client) DownloadDir ¶
func (c *Client) DownloadDir(remoteDir, localDir string, opts *DownloadOptions) (int, error)
DownloadDir 递归下载整个目录 使用统一的任务收集+执行模式,避免并发嵌套
func (*Client) DownloadGlob ¶
func (c *Client) DownloadGlob(pattern, localPath string, opts *DownloadOptions) (int, error)
DownloadGlob 使用 glob 模式匹配下载远程文件
func (*Client) DownloadSources ¶ added in v0.10.0
func (c *Client) DownloadSources(remoteSources []string, localDir string, opts *DownloadOptions) (int, error)
DownloadSources 下载一个或多个远程 source(显式路径或 glob)
func (*Client) DownloadWithProgress ¶
func (c *Client) DownloadWithProgress(remotePath, localPath string, globalBar *progressbar.ProgressBar) error
DownloadWithProgress 下载文件(支持进度条)
func (*Client) ExecuteRemote ¶
ExecuteRemote 在远程服务器执行命令(交互式)
func (*Client) ListCompletion ¶
ListCompletion 获取路径补全候选列表 返回基于用户输入prefix的完整候选路径(保持prefix的格式:绝对/相对)
func (*Client) ResolveLocalPath ¶ added in v0.8.0
ResolveLocalPath 解析本地路径(相对路径转绝对路径) 返回路径统一使用 / 分隔符(SFTP 兼容格式),避免 Windows \ 不被远程服务器识别
func (*Client) ResolveRemotePath ¶ added in v0.8.0
ResolveRemotePath 解析远程路径(相对路径转绝对路径)
func (*Client) UploadDir ¶
func (c *Client) UploadDir(localDir, remoteDir string, opts *UploadOptions) (int, error)
UploadDir 递归上传整个目录 使用统一的任务收集+执行模式,避免并发嵌套
func (*Client) UploadGlob ¶
func (c *Client) UploadGlob(pattern, remotePath string, opts *UploadOptions) (int, error)
UploadGlob 使用 glob 模式匹配上传文件
func (*Client) UploadSources ¶ added in v0.10.0
func (c *Client) UploadSources(localSources []string, remoteDir string, opts *UploadOptions) (int, error)
UploadSources 上传一个或多个本地 source(显式路径或 glob)
func (*Client) UploadWithProgress ¶
func (c *Client) UploadWithProgress(localPath, remotePath string, globalBar *progressbar.ProgressBar) error
UploadWithProgress 上传文件(支持进度条)
type DownloadOptions ¶
type DownloadOptions struct {
Recursive bool // 递归下载目录
ShowProgress bool // 显示进度条
Concurrency int // 并发数
Flatten bool // 扁平化目标路径
MaxDepth int // 最大递归深度:-1=无限, 0=仅当前目录, 1=一层子目录...
}
DownloadOptions 下载选项
type TransferOptions ¶ added in v0.8.0
type TransferOptions struct {
Recursive bool // 递归处理目录
ShowProgress bool // 显示进度条
Concurrency int // 并发数
MaxDepth int // 最大递归深度:-1=无限, 0=仅当前目录, 1=一层子目录...
}
TransferOptions 统一的传输选项
func DefaultTransferOptions ¶ added in v0.8.0
func DefaultTransferOptions() *TransferOptions
DefaultTransferOptions 返回默认传输选项