feat: Use domain name and timestamp in output filename
This commit is contained in:
parent
797ad3c30a
commit
0f7ab0a9f7
13
main.go
13
main.go
|
@ -4,7 +4,9 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -22,8 +24,15 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Create results file with current date
|
||||
filename := fmt.Sprintf("result-%s.txt", time.Now().Format("2006-01-02"))
|
||||
// Extract domain from URL
|
||||
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)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue