diff options
Diffstat (limited to 'bin-src/crtsh-pem2html.go')
-rw-r--r-- | bin-src/crtsh-pem2html.go | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/bin-src/crtsh-pem2html.go b/bin-src/crtsh-pem2html.go index e246654..dd95b55 100644 --- a/bin-src/crtsh-pem2html.go +++ b/bin-src/crtsh-pem2html.go @@ -161,24 +161,6 @@ func (certs CertSet) Updated() time.Time { return ret } -type CertList []CertSet - -// Len is the number of elements in the collection. -func (l CertList) Len() int { - return len(l) -} - -// Less reports whether the element with -// index i should sort before the element with index j. -func (l CertList) Less(i, j int) bool { - return l[i].Updated().After(l[j].Updated()) -} - -// Swap swaps the elements with indexes i and j. -func (l CertList) Swap(i, j int) { - l[i], l[j] = l[j], l[i] -} - func main() { if err := mainWithError(); err != nil { _, _ = fmt.Fprintf(os.Stderr, "%s: error: %v", os.Args[0], err) @@ -223,12 +205,14 @@ func mainWithError() error { bySerial[serial] = append(bySerial[serial], cert) } - var certs CertList + var certs []CertSet for _, set := range bySerial { certs = append(certs, NewCertSet(set)...) } - sort.Sort(certs) + sort.Slice(certs, func(i, j int) bool { + return certs[i].Updated().After(certs[j].Updated()) + }) if err := tmpl.Execute(os.Stdout, map[string]any{"certs": certs, "now": now}); err != nil { return fmt.Errorf("could not execute template: %w", err) } |