Internationalized Resource identifiers (IRI) library for Go
This repository is archived. Ultimately, there was no need for this library.
Furthermore, the realization is also that "Resource Identifier" could be an "unlimited"
data structure, and separate serialization rules then govern whether it becomes an IRI, URI, URL, or whatever flavor (RFC) wanted.
This would be a further (incompatible) rework of the API.
This library provides facilities for working with Internationalized Resource
Identifiers (IRI) as specified in RFC 3987.
RFC reference: https://www.ietf.org/rfc/rfc3987.html
Generally speaking, an IRI is a URI that allows international characters;
And a URI is a generic form of the now rather deprecated URL (= address) and URN (= name).
Although conceptually an IRI is meant to be a generalized concept of a URL,
type iri.IRI
and its functions cannot be used as a drop-in replacement of
net/url.URL
. The standard Go implementation handles many corner cases and
"real life" behaviour of existing systems.
Examples
func ExampleParse_https() {
value, _ := iri.Parse("https://user@example.com/µ/path?q=€#frag1")
fmt.Printf("%#v", value)
}
func ExampleIRI_String_common() {
value := iri.IRI{Scheme: "https", ForceAuthority: false, Authority: "user@example.com", Path: "/sub/path", ForceQuery: false, Query: "q=1", ForceFragment: false, Fragment: "frag1"}
fmt.Printf("%s", value)
}
Origin
The code in this library is forked off from
https://github.com/google/xtoproto/rdf/iri @4cad7286ebfcd65dfec376912eb3b7a03c531c9b
The code from xtoproto
itself is derived from
https://github.com/golang/go/blob/master/src/net/url/url.go ,
which is why the LICENSE
file contains extra information.
A separate repository was created to avoid adding a dependency to an unrelated large library,
just for one small package, which should have been on its own to begin with.
Tag v0.1.0
contains the exact replication of the forked code.
LICENSE
Apache License 2.0, with notice from the Go language project. See LICENSE
file.