diff options
Diffstat (limited to 'skate')
-rw-r--r-- | skate/cdx.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/skate/cdx.go b/skate/cdx.go index 6378bf6..ecf6812 100644 --- a/skate/cdx.go +++ b/skate/cdx.go @@ -25,8 +25,10 @@ type CDXLine struct { Size string } +// CDX contains a number of CDX records. type CDX []CDXLine +// ByDate sorts CDX records by date. type ByDate CDX func (b ByDate) Len() int { @@ -41,6 +43,7 @@ func (b ByDate) Less(i, j int) bool { return b[i].Date < b[j].Date } +// Summary prints a short, task-specific summary to stdout. func (c CDX) Summary() string { var ( dateLast = "NA" @@ -69,7 +72,8 @@ func (c CDX) Summary() string { return fmt.Sprintf("last=%s ok=%s delta=%v", dateLast, dateLastOK, delta) } -// tsDiff returns the duration between two timestamps, like: 20140304124333. +// tsDiff returns the duration between two strings timestamps, like: +// "20140304124333". func tsDiff(a, b string) (time.Duration, error) { ta, err := time.Parse("20060102150405", a) if err != nil { @@ -91,7 +95,7 @@ func tsDiff(a, b string) (time.Duration, error) { // http://www.ijmse.net:80/uploadfile/2016/1214/20161214052559646.pdf // application/pdf 200 PBPHE2OILTB43TAOUO33GBWLE2SS4LQX 2079755 // -// Also returns the raw response body. +// Returns a parsed value, but also the raw response body. func LookupCDX(link string) (result CDX, b []byte, err error) { link = prependSchema(link) cdxlink := fmt.Sprintf("%s?url=%s", cdxApi, link) @@ -116,6 +120,7 @@ func LookupCDX(link string) (result CDX, b []byte, err error) { return result, b, err } +// ParseCDX parses a CDX line (as coming from the API). func ParseCDX(b []byte) (result CDX, err error) { for _, line := range strings.Split(string(b), "\n") { var fields = strings.Fields(line) |