Standard library / crypto/x509
crypto/x509.InvalidReason
Enumerated reason in CertificateInvalidError; inspect it with errors.As rather than matching prose. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type InvalidReason intWorking Example
Example Snippetgo
package main
import ( "crypto/x509" "fmt")
func main() { e := x509.CertificateInvalidError{Reason: x509.Expired} fmt.Println(e.Reason == x509.Expired)}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}