...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package unit
16
17 import (
18 "fmt"
19 )
20
21
22 type UnitOption struct {
23 Section string
24 Name string
25 Value string
26 }
27
28
29 func NewUnitOption(section, name, value string) *UnitOption {
30 return &UnitOption{Section: section, Name: name, Value: value}
31 }
32
33 func (uo *UnitOption) String() string {
34 return fmt.Sprintf("{Section: %q, Name: %q, Value: %q}", uo.Section, uo.Name, uo.Value)
35 }
36
37
38 func (uo *UnitOption) Match(other *UnitOption) bool {
39 return uo.Section == other.Section &&
40 uo.Name == other.Name &&
41 uo.Value == other.Value
42 }
43
44
45
46 func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool {
47 length := len(u1)
48 if length != len(u2) {
49 return false
50 }
51
52 for i := 0; i < length; i++ {
53 if !u1[i].Match(u2[i]) {
54 return false
55 }
56 }
57
58 return true
59 }
60
View as plain text