urn

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Machine

type Machine interface {
	Error() error
	Parse(input []byte) (*URN, error)
}

Machine is the interface representing the FSM

func NewMachine

func NewMachine() Machine

NewMachine creates a new FSM able to parse RFC 2141 strings.

type URN

type URN struct {
	ID string // Namespace identifier
	SS string // Namespace specific string
	// contains filtered or unexported fields
}

URN represents an Uniform Resource Name.

The general form represented is:

urn:<id>:<ss>

Details at https://tools.ietf.org/html/rfc2141.

func Parse

func Parse(u []byte) (*URN, bool)

Parse is responsible to create an URN instance from a byte array matching the correct URN syntax.

func (*URN) Equal

func (u *URN) Equal(x *URN) bool

Equal checks the lexical equivalence of the current URN with another one.

func (URN) MarshalJSON

func (u URN) MarshalJSON() ([]byte, error)

MarshalJSON marshals the URN to JSON string form (e.g. `"urn:oid:1.2.3.4"`).

func (*URN) Normalize

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 (*URN) String

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 (*URN) UnmarshalJSON

func (u *URN) UnmarshalJSON(bytes []byte) error

MarshalJSON unmarshals a URN from JSON string form (e.g. `"urn:oid:1.2.3.4"`).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL