-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud.go
32 lines (29 loc) · 926 Bytes
/
cloud.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package rss2
import (
"encoding/xml"
"fmt"
)
// Cloud represents a Channel's cloud element. All attributes must be
// present.
type Cloud struct {
XMLName xml.Name `xml:"cloud"`
Domain string `xml:"domain,attr"`
Port int `xml:"port,attr"`
Path string `xml:"path,attr"`
RegisterProcedure string `xml:"registerProcedure,attr"`
Protocol string `xml:"protocol,attr"`
}
// NewCloud creates a new Cloud element.
func NewCloud(domain string, port int, path, rp, protocol string) (*Cloud, error) {
if len(domain) == 0 || len(path) == 0 || len(rp) == 0 || len(protocol) == 0 {
return nil, fmt.Errorf(`empty string passed to NewCloud()`)
}
return &Cloud{
XMLName: xml.Name{Local: `cloud`},
Domain: domain,
Port: port,
Path: path,
RegisterProcedure: rp,
Protocol: protocol,
}, nil
}