GolangNote

Golang笔记

使用go-shutil 轻松复制文件

Permalink

Golang 的文件复制很蛋疼,有了go-shutil 妈妈再也不用担心我的文件复制了

示例片断

Go: copy file
1
2
3
4
5
6
7
8
9
10
11
err := CopyFile("test/testfile", "test/testfile3", false)
if err != nil {
  t.Error(err)
  return
}

_, err = Copy("test/testfile2", "test/testfile3", false)
if err != nil {
  t.Error(err)
  return
}

go-shutil 项目地址 https://github.com/termie/go-shutil

本文网址: https://golangnote.com/topic/94.html 转摘请注明来源

Related articles

Go Modules 使用备忘

简单说 Go Modules 就是包管理,从 go1.11 开始支持,可以不需要gopath存在,环境变量`GO111MODULE`,默认为 `auto` 项目存在 `go.mod` 则使用 go module ,否则使用GOPATH 和 vendor 机制。...

golang snappy 的使用场合

google 自家的 snappy 压缩优点是非常高的速度和合理的压缩率。压缩率比 gzip 小,CPU 占用小。...

Write a Comment to "使用go-shutil 轻松复制文件"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.20 Processed in 0ms