1 Star 1 Fork 1

up-zero/gotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
file_test.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
package gotool
import (
"fmt"
"testing"
)
func TestFileCopy(t *testing.T) {
t.Log(FileCopy("LICENSE_BAK", "LICENSE"))
}
func TestFileMove(t *testing.T) {
t.Log(FileMove("/opt/gotool/test/rename.txt", "/opt/gotool/test.txt"))
}
func TestFileDownload(t *testing.T) {
t.Log(FileDownload("https://www.baidu.com/img/bd_logo1.png", "baidu.png"))
}
func (dp *DownloadProgress) printProgress() {
progress := float64(dp.Total) / float64(dp.FileSize) * 100
fmt.Printf("\rDownloading... %.2f%% complete (%d/%d)", progress, dp.Total, dp.FileSize)
}
func TestFileDownloadWithNotify(t *testing.T) {
dp := make(chan DownloadProgress)
go func() {
for data := range dp {
data.printProgress()
}
}()
data, err := FileDownloadWithNotify(dp, "https://www.baidu.com/img/bd_logo1.png", "baidu.png")
if err != nil {
t.Fatal(err)
}
data.printProgress()
}
func TestFileCount(t *testing.T) {
t.Log(FileCount(".", ".go", ".mod"))
}
func TestFileMainName(t *testing.T) {
t.Log(FileMainName("/opt/gotool/test.go"))
t.Log(FileMainName("test.go"))
}
func TestFileSave(t *testing.T) {
err := FileSave("/opt/gotool/test.txt", []byte("hello world"))
if err != nil {
t.Fatal(err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/up-zero/gotool.git
git@gitee.com:up-zero/gotool.git
up-zero
gotool
gotool
main

搜索帮助