File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff 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
1617func 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
2123func (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 )
You can’t perform that action at this time.
0 commit comments