-
Notifications
You must be signed in to change notification settings - Fork 226
/
utils.go
41 lines (34 loc) · 840 Bytes
/
utils.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
package types
// ModuleRow represents a single row inside the modules table
type ModuleRow struct {
Module string `db:"module_name"`
}
// Equal return true if two moduleRow is equal
func (v ModuleRow) Equal(w ModuleRow) bool {
return v.Module == w.Module
}
// ModuleRows represent an array of ModulerRow
type ModuleRows []*ModuleRow
// NewModuleRows return a new instance of ModuleRows
func NewModuleRows(names []string) ModuleRows {
rows := make([]*ModuleRow, 0)
for _, name := range names {
rows = append(rows, &ModuleRow{Module: name})
}
return rows
}
// Equal return true if two ModulesRow is equal
func (v ModuleRows) Equal(w *ModuleRows) bool {
if w == nil {
return false
}
if len(v) != len(*w) {
return false
}
for index, val := range v {
if !val.Equal(*(*w)[index]) {
return false
}
}
return true
}