GetAuthCache gets the auth cache form the cache file.
()
| 160 | |
| 161 | // GetAuthCache gets the auth cache form the cache file. |
| 162 | func GetAuthCache() (cache AuthCache, err error) { |
| 163 | cacheFile := cacheFile() |
| 164 | if cacheFile == "" { |
| 165 | return cache, nil |
| 166 | } |
| 167 | f, err := os.OpenFile(cacheFile, os.O_RDONLY, 0) |
| 168 | if err != nil { |
| 169 | if os.IsNotExist(err) { |
| 170 | return cache, nil |
| 171 | } |
| 172 | return cache, err |
| 173 | } |
| 174 | defer f.Close() // ignore errors |
| 175 | if err = json.NewDecoder(f).Decode(&cache.data); err != nil { |
| 176 | return cache, err |
| 177 | } |
| 178 | return cache, nil |
| 179 | } |
| 180 | |
| 181 | // SaveAuthCache saves the auth cache to the cache file. |
| 182 | func SaveAuthCache(cache AuthCache) (err error) { |
no test coverage detected