()
| 75 | } |
| 76 | |
| 77 | func (c *checker) rest() (*restIndex, error) { |
| 78 | c.restOnce.Do(func() { |
| 79 | path, err := restSource.locate(c.progress) |
| 80 | if err != nil { |
| 81 | c.restErr = err |
| 82 | return |
| 83 | } |
| 84 | data, err := os.ReadFile(path) |
| 85 | if err != nil { |
| 86 | c.restErr = err |
| 87 | return |
| 88 | } |
| 89 | idx, err := loadRESTIndex(data) |
| 90 | if err != nil { |
| 91 | c.restErr = fmt.Errorf("reading %s: %w", path, err) |
| 92 | return |
| 93 | } |
| 94 | c.restIdx = idx |
| 95 | c.restFile = newSchemaFile(restSource, path, data) |
| 96 | }) |
| 97 | return c.restIdx, c.restErr |
| 98 | } |
| 99 | |
| 100 | // preload loads both schemas before gh starts, so a first-time download |
| 101 | // doesn't happen while gh waits for a response. |
no test coverage detected