io

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chmod

func Chmod(path string, permission os.FileMode) error

Chmod 修改文件/目录权限

func Chown

func Chown(path, user, group string) error

Chown 修改文件或目录所有者

func Compress

func Compress(dir string, src []string, dst string) error

Compress 压缩文件

func CountX

func CountX(path string) (int64, error)

CountX 统计目录下文件数

func Cp

func Cp(src, dst string) error

Cp 复制文件或目录(保留所有权和权限)

func DownloadFile

func DownloadFile(url, destPath string) error

DownloadFile 下载文件到指定路径,使用 .tmp 原子替换

func Empty

func Empty(path string) bool

Empty 判断路径是否为空

func Exists

func Exists(path string) bool

Exists 判断路径是否存在

func GetSymlink(path string) string

GetSymlink 获取软链接目标

func IsDir

func IsDir(path string) bool

IsDir 判断是否为目录

func IsHidden

func IsHidden(path string) bool

IsHidden 判断是否为隐藏文件

func IsSymlink(mode os.FileMode) bool

IsSymlink 判读是否为软链接

func ListCompress

func ListCompress(src string) ([]string, error)

ListCompress 获取压缩包内文件列表

func Mv

func Mv(src, dst string) error

func Read

func Read(path string) (string, error)

Read 读取文件

func Remove

func Remove(path string) error

Remove 删除文件/目录

func Search(path, keyword string, sub bool) (map[string]os.FileInfo, error)

Search 查找文件/文件夹

func SearchX

func SearchX(path, keyword string, sub bool) ([]os.DirEntry, error)

SearchX 查找文件/文件夹(find命令)

func Size

func Size(path string) (int64, error)

Size 获取路径大小

func SizeX

func SizeX(path string) (int64, error)

SizeX 获取路径大小(du命令)

func UnCompress

func UnCompress(src string, dst string) error

UnCompress 解压文件

func Write

func Write(path string, data string, permission os.FileMode) error

Write 写入文件

func WriteAppend

func WriteAppend(path string, data string, permission os.FileMode) error

WriteAppend 追加写入文件

Types

type FormatArchive

type FormatArchive string
const (
	Zip      FormatArchive = "zip"
	Gz       FormatArchive = "gz"
	Bz2      FormatArchive = "bz2"
	Tar      FormatArchive = "tar"
	TGz      FormatArchive = "tgz"
	Xz       FormatArchive = "xz"
	SevenZip FormatArchive = "7z"
)

type SearchEntry

type SearchEntry struct {
	// contains filtered or unexported fields
}

SearchEntry 实现 os.DirEntry 接口

func (*SearchEntry) Info

func (d *SearchEntry) Info() (os.FileInfo, error)

Info 返回文件信息

func (*SearchEntry) IsDir

func (d *SearchEntry) IsDir() bool

IsDir 判断是否为目录

func (*SearchEntry) Name

func (d *SearchEntry) Name() string

Name 返回文件基本名称

func (*SearchEntry) Path

func (d *SearchEntry) Path() string

Path 返回文件完整路径

func (*SearchEntry) Type

func (d *SearchEntry) Type() os.FileMode

Type 返回文件模式类型

Jump to

Keyboard shortcuts

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