代码拉取完成,页面将自动刷新
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)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。