Read calls fn with the current copy of the data.
(fn func(data *Data))
| 62 | |
| 63 | // Read calls fn with the current copy of the data. |
| 64 | func (p *JSONFile[Data]) Read(fn func(data *Data)) { |
| 65 | p.mu.RLock() |
| 66 | defer p.mu.RUnlock() |
| 67 | fn(p.data) |
| 68 | } |
| 69 | |
| 70 | // Write calls fn with a copy of the data, then writes the changes to the file. |
| 71 | // If fn returns an error, Write does not change the file and returns the error. |
no outgoing calls