26 lines
440 B
Go
26 lines
440 B
Go
|
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
|
||
|
}
|