diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ecd0ab9 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module streifling.com/jason/atom-feed + +go 1.23.2 + +require github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7790d7c --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/id.go b/id.go index de938f0..180070f 100644 --- a/id.go +++ b/id.go @@ -1,12 +1,21 @@ package atomfeed -import "errors" +import ( + "errors" + "fmt" + + "github.com/google/uuid" +) type ID struct { *CommonAttributes URI URI `xml:"uri"` } +func NewID() *ID { + return &ID{URI: URI(fmt.Sprint("urn:uuid:", uuid.New()))} +} + func (i *ID) Check() error { if i.URI == "" { return errors.New("uri element of id empty")