summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..10709e2
--- /dev/null
+++ b/util.go
@@ -0,0 +1,43 @@
1package main
2
3import (
4 "net/url"
5 "strings"
6)
7
8type stringSet struct {
9 values map[string]bool
10}
11
12func NewStringSet(values ...string) *stringSet {
13 s := &stringSet{
14 values: make(map[string]bool, len(values)),
15 }
16
17 for _, v := range values {
18 s.Add(v)
19 }
20
21 return s
22}
23
24func (s *stringSet) Add(v string) {
25 s.values[v] = true
26}
27
28func (s *stringSet) Contains(k string) bool {
29 _, ok := s.values[k]
30 return ok
31}
32
33func URLMustParse(u string) *url.URL {
34 o, err := url.Parse(u)
35 if err != nil {
36 panic(err)
37 }
38 return o
39}
40
41func CompareUpper(lhs, rhs string) bool {
42 return strings.ToUpper(lhs) == strings.ToUpper(rhs)
43}