-
-
Notifications
You must be signed in to change notification settings - Fork 276
/
helpers.go
48 lines (37 loc) 路 786 Bytes
/
helpers.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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Popeye
package config
import "regexp"
var invalidPathCharsRX = regexp.MustCompile(`[:/]+`)
func in(oo []string, p *string) bool {
if p == nil {
return true
}
for _, o := range oo {
if o == *p {
return true
}
}
return false
}
// SanitizeFileName ensure file spec is valid.
func SanitizeFileName(name string) string {
return invalidPathCharsRX.ReplaceAllString(name, "-")
}
// IsStrSet checks string option is set.
func IsStrSet(s *string) bool {
return s != nil && *s != ""
}
// IsBoolSet checks bool option is set
func IsBoolSet(s *bool) bool {
return s != nil && *s
}
func boolPtr(b bool) *bool {
return &b
}
func strPtr(s string) *string {
return &s
}
func intPtr(i int) *int {
return &i
}