feat: Capture start time for consistent filename timestamp

This commit is contained in:
Erik Winter (aider) 2025-02-01 12:07:13 +01:00
parent 0f7ab0a9f7
commit e51702fb74
1 changed files with 4 additions and 1 deletions

View File

@ -18,6 +18,9 @@ func main() {
log.Fatal("Please provide a URL using the -url flag")
}
// Start time for the filename
startTime := time.Now()
checker := NewLinkChecker()
brokenLinks, err := checker.CheckLinks(*url)
if err != nil {
@ -32,7 +35,7 @@ func main() {
domain := strings.TrimPrefix(parsedURL.Hostname(), "www.")
// Create results file with domain and timestamp
filename := fmt.Sprintf("%s-%s.txt", domain, time.Now().Format("2006-01-02-150405"))
filename := fmt.Sprintf("%s-%s.txt", domain, startTime.Format("2006-01-02-150405"))
f, err := os.Create(filename)
if err != nil {
log.Fatal(err)