go-urn – github.com/leodido/go-urn Index | Files

package urn

import "github.com/leodido/go-urn"

Package urn implements RFC 2141.

It provides a parser capable, given a string respecting valid syntax as per RFC 2141, to instantiate an URN type. Furthermore this package provides methods to perform normalization and lexical equivalence on URN instances.

Index

Types

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 string) (*URN, bool)

Parse is responsible to create an URN instance from a string 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) 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".

Source Files

urn.go

Version
v1.0.0
Published
Dec 11, 2017
Platform
js/wasm
Imports
2 packages
Last checked
now

Tools for package owners.