Add function to create a new ID
This commit is contained in:
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")
|
||||
|
Reference in New Issue
Block a user