23 lines
395 B
Go
23 lines
395 B
Go
|
package gobstore_test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.bivouac.wiki/use/gobstore"
|
||
|
)
|
||
|
|
||
|
func ExampleStore() {
|
||
|
type FooBar struct{ Greeting string }
|
||
|
A := gobstore.NewStore[FooBar]("./", "file.gob")
|
||
|
A.Load()
|
||
|
A.Hidden_save()
|
||
|
//go A.WatchFlush()
|
||
|
A.Set("foobar", FooBar{Greeting: "Hello"})
|
||
|
resp, ok := A.Get("foobar")
|
||
|
if !ok {
|
||
|
fmt.Println("missing!")
|
||
|
}
|
||
|
fmt.Println(resp.Greeting)
|
||
|
// Output: Hello
|
||
|
}
|