Documentation
¶
Index ¶
- func CookieJarFromFile(filePath string) (*cookiejar.Jar, error)
- func ExtractDomain(url string) string
- func FileExtension(filename string) string
- func FormatBytes(bytes int64) string
- func FormatDuration(seconds time.Duration) string
- func IsValidURL(url string) bool
- func MergeHeader(original, additional http.Header) http.Header
- func SanitizeFilename(filename string) string
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CookieJarFromFile ¶
CookieJarFromFile loads cookies from Mozilla cookies.sqlite or Netscape cookies.txt
func FileExtension ¶
FileExtension returns the file extension (including the dot) from a filename or URL. If the filename starts with a dot and has no other dot, it returns an empty string (e.g., ".hiddenfile" -> ""). If there is no extension, it returns an empty string.
func FormatBytes ¶
FormatBytes converts bytes to human readable string
func FormatDuration ¶
FormatDuration formats a duration in seconds to a human-readable string
func MergeHeader ¶
MergeHeader merges two http.Header objects into one.
func SanitizeFilename ¶
SanitizeFilename removes invalid characters from filename
Types ¶
type RateLimiter ¶
type RateLimiter struct {
io.Reader
Rate int64 // bytes per second
// contains filtered or unexported fields
}
RateLimiter wraps an io.Reader and limits the read speed to the specified bytes per second. RateLimiter implements io.ReadCloser for compatibility with io.ReadCloser chains.
func NewRateLimiter ¶
func NewRateLimiter(r io.Reader, rate int64) *RateLimiter
NewRateLimiter creates a new RateLimiter for the given reader and rate (bytes/sec).
func (*RateLimiter) Close ¶
func (rl *RateLimiter) Close() error
Close closes the underlying reader if possible.