()
| 31 | } |
| 32 | |
| 33 | func (gohanClientCLI *GohanClientCLI) getCachedSchemas() ([]*schema.Schema, error) { |
| 34 | rawCache, err := ioutil.ReadFile(gohanClientCLI.opts.cachePath) |
| 35 | if err != nil { |
| 36 | return gohanClientCLI.getSchemas() |
| 37 | } |
| 38 | cache := Cache{} |
| 39 | err = json.Unmarshal(rawCache, &cache) |
| 40 | if err != nil { |
| 41 | return gohanClientCLI.getSchemas() |
| 42 | } |
| 43 | if time.Now().After(cache.Expire) { |
| 44 | return gohanClientCLI.getSchemas() |
| 45 | } |
| 46 | return cache.Schemas, nil |
| 47 | } |
| 48 | |
| 49 | func (gohanClientCLI *GohanClientCLI) setCachedSchemas() error { |
| 50 | cache := Cache{ |
no test coverage detected