package gobstore import ( "encoding/gob" "errors" "fmt" "os" ) // Load initializes the data from disk func (j *GobStore[T]) Load() { // no lock fmt.Println(j.ROOT_DATA_PATH + j.path) file, err := os.Open(j.ROOT_DATA_PATH + j.path) if err != nil { if errors.Is(err, os.ErrNotExist) { fmt.Printf("Gob file does not exist: %s\n", j.path) j.values = map[string]T{} return } fmt.Println(err) } var res map[string]T dec := gob.NewDecoder(file) dec.Decode(&res) if err != nil { fmt.Println(err) } j.values = res j.dirty = false }