sftp

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exist

func Exist(sftpClient *sftp.Client, sPath string) (bool, error)

Exist 判断路径是否存在 如果存在返回true, 当返回false的时候,需要判断error是否未nil,ni来的时候标识文件夹不存在

func Mkdir

func Mkdir(sftpClient *sftp.Client, sPath string) error

Mkdir 创建文件夹

func SetPath

func SetPath(sftpClient *sftp.Client, sPath string) (string, error)

SetPath 设置当前 文件全路径 sPath 如果是绝对路径,那么直接返回sPath 如果是相对路径,会跟上当前目录

Types

type Config

type Config struct {
	Host           string `json:"host" yaml:"host" ini:"host"` // 路径
	User           string `json:"user" yaml:"user" ini:"user"`
	Pwd            string `json:"pwd" yaml:"pwd" ini:"pwd"`                                  // 密码|密钥
	Authentication string `json:"authentication" yaml:"authentication" ini:"authentication"` // 认证方式 ,默认passwd,可选public_key
	// contains filtered or unexported fields
}

Config sftp 配置

func (*Config) Close

func (this *Config) Close()

Close 关闭 ssh 和 sftp

func (*Config) CloseSftp

func (this *Config) CloseSftp()

CloseSftp 关闭 sftp

func (*Config) CloseSsh

func (this *Config) CloseSsh()

CloseSsh 关闭 ssh

func (*Config) Delete

func (this *Config) Delete(p string) error

func (*Config) DeleteAll

func (this *Config) DeleteAll(p string) error

func (Config) GormDBDataType

func (Config) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (Config) GormDataType

func (this Config) GormDataType() string

func (*Config) ListFiles

func (this *Config) ListFiles(dirPath string) ([]string, error)

func (*Config) LoginSftp

func (this *Config) LoginSftp() error

LoginSftp ssh登录 @return , error

func (*Config) LoginSsh

func (this *Config) LoginSsh() error

LoginSsh 登录 ssh

func (*Config) Read

func (this *Config) Read(p string) (io.ReadCloser, error)

Read 读取文件

func (*Config) RemovePasswd

func (this *Config) RemovePasswd()

func (*Config) Scan

func (this *Config) Scan(val interface{}) error

func (*Config) SetInfo

func (this *Config) SetInfo(args ...any)

func (*Config) Valid

func (this *Config) Valid() error

func (Config) Value

func (this Config) Value() (driver.Value, error)

func (*Config) Write

func (this *Config) Write(p string, src io.Reader, existIgnores ...bool) (int64, error)

Write 写入文件

Jump to

Keyboard shortcuts

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