Fixing styling issues for caching.

This commit is contained in:
Burcu Dogan
2014-05-22 14:33:36 +02:00
parent 0476447419
commit 6bb3577bf0
3 changed files with 18 additions and 14 deletions

View File

@@ -24,8 +24,11 @@ func NewFileCache(filename string) *FileCache {
// FileCache represents a file based token cacher.
type FileCache struct {
filename string
ErrorHandlerFunc func(error)
// Handler to be invoked if an error occurs
// during read or write operations.
ErrorHandler func(error)
filename string
}
// Read reads a cache token from the specified file.
@@ -34,8 +37,8 @@ func (f *FileCache) Read() (token *Token) {
if err == nil {
err = json.Unmarshal(data, token)
}
if f.ErrorHandlerFunc != nil {
f.ErrorHandlerFunc(err)
if f.ErrorHandler != nil {
f.ErrorHandler(err)
}
return
}
@@ -46,7 +49,7 @@ func (f *FileCache) Write(token *Token) {
if err == nil {
err = ioutil.WriteFile(f.filename, data, 0644)
}
if f.ErrorHandlerFunc != nil {
f.ErrorHandlerFunc(err)
if f.ErrorHandler != nil {
f.ErrorHandler(err)
}
}