path

package
v0.0.0-...-a11b62f Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// HomeDir 用户家目录
	HomeDir string
	// TempDir 临时目录
	TempDir string
	// Home 家目录
	Home *Path
)

Functions

func Expand

func Expand(p string) (path string)

Expand 扩展路径

func InitLog

func InitLog()

InitLog 初始化日志文件 放在 $HOME/.logs/date 目录下,并且用命令作为文件名

Types

type Path

type Path struct {
	Raw string
	// contains filtered or unexported fields
}

Path 目录

func NewPath

func NewPath(path string) (p *Path)

NewPath 目录构造函数

func (*Path) Base

func (p *Path) Base() string

Base 文件名

func (*Path) Clean

func (p *Path) Clean() string

Clean 整理文件

func (*Path) Dir

func (p *Path) Dir() string

Dir 目录

func (*Path) Ensure

func (p *Path) Ensure() error

Ensure 确保目录存在

func (*Path) Ext

func (p *Path) Ext() string

Ext 扩展名

func (*Path) FileInfo

func (p *Path) FileInfo() (info os.FileInfo)

FileInfo 获取文件信息

func (*Path) Find

func (p *Path) Find(pattern string) (path string)

Find 在目录中查找记录

func (*Path) Glob

func (p *Path) Glob(pattern string) (matches []string)

Glob 查找文件

func (*Path) IsExist

func (p *Path) IsExist() bool

IsExist 判断目录是否存在

func (*Path) Join

func (p *Path) Join(elem ...string) (path *Path)

Join 连接目录

func (*Path) MakeDir

func (p *Path) MakeDir() error

MakeDir 创建目录

func (*Path) MakeDirAll

func (p *Path) MakeDirAll() error

MakeDirAll 创建目录

func (*Path) Match

func (p *Path) Match(pattern string) (matched bool)

Match 判断是否匹配

func (*Path) Open

func (p *Path) Open() (io.ReadCloser, error)

Open 打开文件

func (*Path) Remove

func (p *Path) Remove() error

Remove 删除文件

func (*Path) Split

func (p *Path) Split() (dir, name string)

Split 拆分文件名,将文件名拆分行目录和文件名

func (*Path) String

func (p *Path) String() string

String 转换成字符串

func (*Path) WithExt

func (p *Path) WithExt(ext string) *Path

WithExt 替换成指定的扩展名

Jump to

Keyboard shortcuts

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