Add function to create a new ID
This commit is contained in:
parent
8bfd8a648e
commit
9ec6ad1460
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module streifling.com/jason/atom-feed
|
||||
|
||||
go 1.23.2
|
||||
|
||||
require github.com/google/uuid v1.6.0
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -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=
|
11
id.go
11
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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user