-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.go
More file actions
25 lines (22 loc) · 675 Bytes
/
Copy pathutils.go
File metadata and controls
25 lines (22 loc) · 675 Bytes
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
package ltreevisualizer
import (
"context"
log "github.com/sirupsen/logrus"
"strings"
"time"
)
//CalculateTimeTaken calculates the time taken to complete the execution of a method
func CalculateTimeTaken(ctx context.Context, start time.Time, name string) {
logger := log.WithContext(ctx).WithFields(log.Fields{"Method": "CalculateTimeTaken"})
elapsed := time.Since(start)
logger.Debugf("%s took %s", name, elapsed)
}
//Contains Check if a search term is available in a slice, returns bool
func Contains(list []string, searchTerm string) bool {
for _, s := range list {
if strings.ToLower(s) == strings.ToLower(searchTerm) {
return true
}
}
return false
}