summaryrefslogtreecommitdiff
path: root/bin-src/tls-pem2html.go
diff options
context:
space:
mode:
Diffstat (limited to 'bin-src/tls-pem2html.go')
-rw-r--r--bin-src/tls-pem2html.go24
1 files changed, 4 insertions, 20 deletions
diff --git a/bin-src/tls-pem2html.go b/bin-src/tls-pem2html.go
index dcf22ba..ffb3416 100644
--- a/bin-src/tls-pem2html.go
+++ b/bin-src/tls-pem2html.go
@@ -100,24 +100,6 @@ func (cert Cert) Class() string {
}
}
-type Certs []Cert
-
-// Len is the number of elements in the collection.
-func (l Certs) Len() int {
- return len(l)
-}
-
-// Less reports whether the element with
-// index i should sort before the element with index j.
-func (l Certs) Less(i, j int) bool {
- return l[i].X509.NotAfter.After(l[j].X509.NotAfter)
-}
-
-// Swap swaps the elements with indexes i and j.
-func (l Certs) 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)
@@ -131,7 +113,7 @@ func mainWithError() error {
return fmt.Errorf("reading stdin: %w", err)
}
- var certs Certs
+ var certs []Cert
for len(data) > 0 {
var certPem *pem.Block
certPem, data = pem.Decode(data)
@@ -154,7 +136,9 @@ func mainWithError() error {
certs = append(certs, cert)
}
- sort.Sort(certs)
+ sort.Slice(certs, func(i, j int) bool {
+ return certs[i].X509.NotAfter.After(certs[j].X509.NotAfter)
+ })
if err := tmpl.Execute(os.Stdout, map[string]any{"certs": certs, "now": now}); err != nil {
return fmt.Errorf("executing template: %w", err)
}