forked from ikeikeikeike/go-sitemap-generator
/
builder.go
61 lines (47 loc) · 1.21 KB
/
builder.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package stm
import (
"fmt"
)
var poolBuffer = NewBufferPool()
// BuilderError provides interface for it can confirm the error in some difference.
type BuilderError interface {
error
FullError() bool
}
// Builder provides interface for adds some kind of url sitemap.
type Builder interface {
XMLContent() []byte
Content() []byte
Add(interface{}) BuilderError
Write()
}
// SitemapURL provides generated xml interface.
type SitemapURL interface {
XML() []byte
}
// Attrs defines for xml attribute.
type Attrs []interface{}
// Attr defines for xml attribute.
type Attr map[string]string
// URL User should use this typedef in main func.
type URL map[string]interface{}
// URLJoinBy that's convenient.
func (u URL) URLJoinBy(key string, joins ...string) URL {
var values []string
for _, k := range joins {
values = append(values, fmt.Sprint(u[k]))
}
u[key] = URLJoin("", values...)
return u
}
// BungURLJoinBy that's convenient. Though, this is Bung method.
func (u *URL) BungURLJoinBy(key string, joins ...string) {
orig := *u
var values []string
for _, k := range joins {
values = append(values, fmt.Sprint(orig[k]))
}
orig[key] = URLJoin("", values...)
*u = orig
}
// type News map[string]interface{}