-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cache | ||
|
||
import "sync" | ||
|
||
// URLCache is a struct to hold the visited URLs | ||
type URLCache struct { | ||
mu sync.Mutex | ||
URLs map[string]bool | ||
} | ||
|
||
// Add adds a URL to the cache | ||
func (c *URLCache) Add(url string) { | ||
c.mu.Lock() | ||
defer c.mu.Unlock() | ||
c.URLs[url] = true | ||
} | ||
|
||
// Get checks if a URL is in the cache | ||
func (c *URLCache) Get(url string) bool { | ||
c.mu.Lock() | ||
defer c.mu.Unlock() | ||
_, ok := c.URLs[url] | ||
return ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package config | ||
|
||
type Config struct { | ||
Scrape ScrapeConfig `mapstructure:"scrape"` | ||
Sitemap SitemapConfig `mapstructure:"sitemap"` | ||
} | ||
|
||
type SitemapConfig struct { | ||
Dir string `mapstructure:"dir"` | ||
URL string `mapstructure:"url"` | ||
ReplaceURL string `mapstructure:"replace-url"` | ||
File string `mapstructure:"file"` | ||
} | ||
|
||
type ScrapeConfig struct { | ||
Dir string `mapstructure:"dir"` | ||
URL string `mapstructure:"url"` | ||
Cache string `mapstructure:"cache"` | ||
ReplaceURL string `mapstructure:"replace-url"` | ||
Replace bool `mapstructure:"replace"` | ||
Parallel bool `mapstructure:"parallel"` | ||
Images bool `mapstructure:"images"` | ||
CheckHead bool `mapstructure:"check-head"` | ||
} |