Skip to content

Commit bd5d23f

Browse files
committed
refactor: compare mod time directly, annotate exported symbols
1 parent e0896f1 commit bd5d23f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

decode.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ type cachedDecoder struct {
1313
ext string
1414
}
1515

16+
// CachedDecoder gives a managed decoder that caches a copy of json5 transitioned to json
1617
func CachedDecoder(ext ...string) *cachedDecoder {
1718
ext = append(ext, ".cached.json")
1819
return &cachedDecoder{New(), ext[0]}
1920
}
2021

22+
// Decode decodes from cache if exists and relevant else decodes from source
2123
func (fd *cachedDecoder) Decode(file string, v interface{}) error {
2224
stat, err := os.Stat(file)
2325
if err != nil {
@@ -32,7 +34,7 @@ func (fd *cachedDecoder) Decode(file string, v interface{}) error {
3234
}
3335

3436
// Update if not exist, or source file modified
35-
update := !exist || stat.ModTime().UnixMilli() != cstat.ModTime().UnixMilli()
37+
update := !exist || stat.ModTime() != cstat.ModTime()
3638
if !update {
3739
jsonb, _ := ioutil.ReadFile(cache)
3840
return json.Unmarshal(jsonb, v)

0 commit comments

Comments
 (0)