30 lines
		
	
	
		
			443 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			443 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package atomfeed
 | 
						|
 | 
						|
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")
 | 
						|
	} else {
 | 
						|
		if !isValidURI(i.URI) {
 | 
						|
			return fmt.Errorf("uri element %v of id not correctly formatted", i.URI)
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	return nil
 | 
						|
}
 |