Completed
Push — master ( 7018f6...dde30f )
by Serhii
18s queued 15s
created

timeago.isFilePresent   A

Complexity

Conditions 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
dl 0
loc 11
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
nop 1
1
package timeago
2
3
import (
4
	"encoding/json"
5
	"fmt"
6
	"time"
7
)
8
9
func unixToTime(userDate int) time.Time {
10
	return time.Unix(int64(userDate), 0)
11
}
12
13
func parseLangSet(filePath string) (*LangSet, error) {
14 1
	content, err := langsFS.ReadFile(filePath)
15
	if err != nil {
16 1
		return nil, fmt.Errorf("could not read language file: %w", err)
17 1
	}
18
19
	langSet := &LangSet{}
20 1
21 1
	if err := json.Unmarshal(content, &langSet); err != nil {
22
		return nil, fmt.Errorf("could not unmarshal language file: %w", err)
23
	}
24
25
	return langSet, nil
26
}
27