From b496ac3691ffe4ae52102812bd5fc0dc36a1fe2c Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Thu, 17 Oct 2024 16:52:03 +0200 Subject: [PATCH] Allow the user to generate a valid iri based on a uuid --- atom.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/atom.go b/atom.go index 8e1b443..b5e6671 100644 --- a/atom.go +++ b/atom.go @@ -1,10 +1,12 @@ package atom import ( + "fmt" "mime" "regexp" "strings" + "github.com/google/uuid" "golang.org/x/text/language" ) @@ -79,3 +81,8 @@ func isValidLanguageTag(tag LanguageTag) bool { _, err := language.Parse(string(tag)) return err == nil } + +// NewURN generates an new valid IRI based on a UUID. It returns an IRI. +func NewURN() IRI { + return IRI(fmt.Sprint("urn:uuid:", uuid.New())) +}