Skip to content

Commit

Permalink
addtime
Browse files Browse the repository at this point in the history
  • Loading branch information
SunEve committed May 7, 2024
1 parent 9ff2719 commit d1e516b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions autotv.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,41 @@ func downloadFile(url, filepath string) error {
return nil
}

func gettime() {
// 获取当前时间
currentTime := time.Now()

Check failure on line 37 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: time

// 格式化时间为字符串
timeString := currentTime.Format("2006-01-02 15:04:05") + "\n"

// 打开文件以追加文本
filePath := "update_time.txt"
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println("打开文件时出错:", err)
return
}
defer file.Close()

// 将时间字符串写入文件
_, err = file.WriteString(timeString)
if err != nil {
fmt.Println("写入文件时出错:", err)
return
}

fmt.Printf("当前时间已追加到文件 %s\n", filePath)
}

func main() {
gettime()

fileURL := "https://iitzh.com/cn.m3u"
filePath := "cn.m3u"

err := downloadFile(fileURL, filePath)
if err != nil {
fmt.Println("下载文件时出错:", err)
}

}
Empty file added update_time.txt
Empty file.

0 comments on commit d1e516b

Please sign in to comment.