JSONFile holds a Go value of type Data and persists it to a JSON file. Data is accessed and modified using the Read and Write methods. Create a JSONFile using the New or Load functions.
| 17 | // Data is accessed and modified using the Read and Write methods. |
| 18 | // Create a JSONFile using the New or Load functions. |
| 19 | type JSONFile[Data any] struct { |
| 20 | path string |
| 21 | |
| 22 | mu sync.RWMutex |
| 23 | bytes []byte |
| 24 | data *Data |
| 25 | } |
| 26 | |
| 27 | // New creates a new empty JSONFile at the given path. |
| 28 | func New[Data any](path string) (*JSONFile[Data], error) { |
nothing calls this directly
no outgoing calls
no test coverage detected