2 Star 15 Fork 10

北京小程科技有限公司/Go通用工具

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
copy_file.go 437 Bytes
一键复制 编辑 原始数据 按行查看 历史
shallot 提交于 2019-06-12 01:17 +08:00 . 添加日志记录器和相关接口。
package filesystem
import (
"io"
"os"
)
// 拷贝文件,从source到dest。
func CopyFile(source string, dest string) (written int64, err error) {
sourceFile, err := os.Open(source)
if err != nil {
return
}
defer sourceFile.Close()
destFile, err := os.Create(dest)
if err != nil {
return
}
defer destFile.Close()
written, err = io.Copy(destFile, sourceFile)
if err != nil {
return
}
_ = destFile.Sync()
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xiaochengtech/common.git
git@gitee.com:xiaochengtech/common.git
xiaochengtech
common
Go通用工具
82269be32710

搜索帮助