-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
57 lines (46 loc) · 975 Bytes
/
types.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
package main
type Direction string
func (d Direction) String() string {
return string(d)
}
func (d *Direction) Set(v string) error {
switch v {
case "TB", "BT", "LR", "RL":
*d = Direction(v)
return nil
default:
*d = ""
}
return nil
}
func (d Direction) Type() string {
return `"TB"|"BT"|"LR"|"RL"`
}
type ModuleName string
type ModuleMatchingFunc func(m ModuleName) bool
type DependencyChain struct {
chain []ModuleName
}
func NewDependencyChain(startModule ModuleName) DependencyChain {
return DependencyChain{
chain: []ModuleName{startModule},
}
}
func (c DependencyChain) Add(dep ModuleName) DependencyChain {
newChain := make([]ModuleName, len(c.chain))
copy(newChain, c.chain)
return DependencyChain{
chain: append(newChain, dep),
}
}
func (c DependencyChain) Has(dep ModuleName) bool {
for _, d := range c.chain {
if dep == d {
return true
}
}
return false
}
func (c DependencyChain) Deps() []ModuleName {
return c.chain
}