feat: Use domain name and timestamp in output filename

This commit is contained in:
Erik Winter (aider) 2025-02-01 12:06:23 +01:00
parent 797ad3c30a
commit 0f7ab0a9f7
1 changed files with 11 additions and 2 deletions

13
main.go
View File

@ -4,7 +4,9 @@ import (
"flag" "flag"
"fmt" "fmt"
"log" "log"
"net/url"
"os" "os"
"strings"
"time" "time"
) )
@ -22,8 +24,15 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
// Create results file with current date // Extract domain from URL
filename := fmt.Sprintf("result-%s.txt", time.Now().Format("2006-01-02")) parsedURL, err := url.Parse(*url)
if err != nil {
log.Fatal(err)
}
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"))
f, err := os.Create(filename) f, err := os.Create(filename)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)