const DefaultParsingMode = RFC2141Only
type Kind int
const ( NONE Kind = iota RFC2141 RFC7643 RFC8141 )
Machine is the interface representing the FSM
type Machine interface { Error() error Parse(input []byte) (*URN, error) WithParsingMode(ParsingMode) }
func NewMachine(options ...Option) Machine
NewMachine creates a new FSM able to parse RFC 2141 strings.
type Option func(Machine)
func WithParsingMode(mode ParsingMode) Option
type ParsingMode int
const ( Default ParsingMode = iota RFC2141Only RFC7643Only RFC8141Only )
type SCIM struct { Type scimschema.Type Name string Other string // contains filtered or unexported fields }
func (s SCIM) MarshalJSON() ([]byte, error)
func (s *SCIM) String() string
func (s *SCIM) UnmarshalJSON(bytes []byte) error
URN represents an Uniform Resource Name.
The general form represented is:
urn:<id>:<ss>
Details at https://tools.ietf.org/html/rfc2141.
type URN struct { ID string // Namespace identifier (NID) SS string // Namespace specific string (NSS) // contains filtered or unexported fields }
func Parse(u []byte, options ...Option) (*URN, bool)
Parse is responsible to create an URN instance from a byte array matching the correct URN syntax (RFC 2141).
▹ Example
▹ Example (Scim)
func (u *URN) Equal(x *URN) bool
Equal checks the lexical equivalence of the current URN with another one.
▹ Example
func (u *URN) FComponent() string
func (u *URN) IsSCIM() bool
func (u URN) MarshalJSON() ([]byte, error)
MarshalJSON marshals the URN to JSON string form (e.g. `"urn:oid:1.2.3.4"`).
▹ Example
func (u *URN) Normalize() *URN
Normalize turns the receiving URN into its norm version.
Which means: lowercase prefix, lowercase namespace identifier, and immutate namespace specific string chars (except <hex> tokens which are lowercased).
func (u *URN) QComponent() string
func (u *URN) RComponent() string
func (u *URN) RFC() Kind
func (u *URN) SCIM() *SCIM
func (u *URN) String() string
String reassembles the URN into a valid URN string.
This requires both ID and SS fields to be non-empty. Otherwise it returns an empty string.
Default URN prefix is "urn".
func (u *URN) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals a URN from JSON string form (e.g. `"urn:oid:1.2.3.4"`).
type URN8141 struct { *URN }
func (u URN8141) MarshalJSON() ([]byte, error)
func (u *URN8141) UnmarshalJSON(bytes []byte) error