gobstore/hidden_save.go

26 lines
440 B
Go
Raw Permalink Normal View History

2025-01-12 09:51:51 +00:00
package gobstore
import (
"encoding/gob"
"fmt"
"os"
)
func (j *GobStore[T]) Hidden_save() { // exporting.... on close
// no lock
defer timer("GobStore save")()
file, err := os.Create(j.ROOT_DATA_PATH + j.path)
if err != nil {
fmt.Println(err)
}
fmt.Println("save " + j.path)
fmt.Println(len(j.values))
enc := gob.NewEncoder(file)
err = enc.Encode(j.values)
if err != nil {
fmt.Println(err)
return
}
j.dirty = false
}