golang文件相关的函数

func Create(name string) (file *File, err error) 直接通过纹面创建文件
func NewFile(fd uintptr, name string) *File
func Open(name string) (file *File, err error) 以只读方式打开一个存在的文件,打开就可以读取了。
func OpenFile(name string, flag int, perm FileMode) (file *File, err error)
func Pipe() (r *File, w *File, err error) 管道
func (f *File) Chdir() error 改变当前的工作目录
func (f *File) Chmod(mode FileMode) error 改变权限
func (f *File) Chown(uid, gid int) error 改变所有者
func (f *File) Close() error 关闭文件
func (f *File) Fd() uintptr 返回文件句柄
func (f *File) Name() string 返回文件名
func (f *File) Read(b []byte) (n int, err error) 读取文件
func (f *File) ReadAt(b []byte, off int64) (n int, err error) 从off开始读取文件
func (f *File) Readdir(n int) (fi []FileInfo, err error) 读取文件目录返回n个fileinfo
func (f *File) Readdirnames(n int) (names []string, err error) 读取文件目录返回n个文件名
func (f *File) Seek(offset int64, whence int) (ret int64, err error) 设置读写文件的偏移量,whence为0表示相对于文件的开始处,1表示相对于当前的位置,2表示相对于文件结尾。他返回偏移量。如果有错误返回错误
func (f *File) Stat() (fi FileInfo, err error) 返回当前文件fileinfo结构体
func (f *File) Sync() (err error) 把当前内容持久化,一般就是马上写入到磁盘
func (f *File) Truncate(size int64) error 改变当前文件的大小,他不改变当前文件读写的偏移量
func (f *File) Write(b []byte) (n int, err error) 写入内容
func (f *File) WriteAt(b []byte, off int64) (n int, err error) 在offset位置写入内容
func (f *File) WriteString(s string) (ret int, err error) 写入字符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值