Standard library / crypto/x509/pkix
crypto/x509/pkix.Name
Distinguished name fields including CommonName, organization, country and ExtraNames. Display form is not a canonical identity; SANs are used for hostname checks. Expected stdout: 'CN=Demo\n'.
Formal Syntax & Structure
go syntaxgo
type Name struct { Country, Organization, OrganizationalUnit []string Locality, Province []string StreetAddress, PostalCode []string SerialNumber, CommonName string
Names []AttributeTypeAndValue
ExtraNames []AttributeTypeAndValue}Working Example
Example Snippetgo
package main
import ( "crypto/x509/pkix" "fmt")
func main() { n := pkix.Name{CommonName: "Demo"}; fmt.Println(n.String()) }
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) }}