-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (26 loc) 路 718 Bytes
/
Copy pathmain.go
File metadata and controls
33 lines (26 loc) 路 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"context"
"log"
"os"
"github.com/Snider/Borg/pkg/website"
)
func main() {
log.Println("Collecting website...")
// Download and package the website.
dn, err := website.DownloadAndPackageWebsite(context.Background(), "https://example.com", 2, 1, 0, nil)
if err != nil {
log.Fatalf("Failed to collect website: %v", err)
}
// Serialize the DataNode to a tarball.
tarball, err := dn.ToTar()
if err != nil {
log.Fatalf("Failed to serialize datanode to tar: %v", err)
}
// Write the tarball to a file.
err = os.WriteFile("website.dat", tarball, 0644)
if err != nil {
log.Fatalf("Failed to write datanode file: %v", err)
}
log.Println("Successfully created website.dat")
}