Passed
Push — master ( 58c7cb...3aad29 )
by Serhii
03:52 queued 02:07
created

timeago.SetConfig   A

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 2
nop 1
1
package timeago
2
3
type Translation struct {
4
	Language     string
5
	Translations map[string]string
6
}
7
8
type Config struct {
9
	Language     string
10
	Location     string
11
	Translations []Translation
12
}
13
14
var config = Config{
15
	Language:     "en",
16
	Location:     "",
17
	Translations: []Translation{},
18
}
19
20
func SetConfig(conf Config) {
21 1
	if conf.Language == "" {
22 1
		conf.Language = config.Language
23
	}
24
25 1
	config = conf
26
}
27
28
func locationIsSet() bool {
29 1
	return config.Location != ""
30
}
31
32
func locationIsNotSet() bool {
33
	return !locationIsSet()
34
}
35
36
func translationsAreSet() bool {
37 1
	return len(config.Translations) > 0
38
}
39