diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc6cb7f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +test/basic/basic +test/basic/pgen.go +test/basic/db diff --git a/cmd/pgen/template.go b/cmd/pgen/template.go index ae414b0..27ac21f 100644 --- a/cmd/pgen/template.go +++ b/cmd/pgen/template.go @@ -2,6 +2,7 @@ package main const template string = `package main import ( + "encoding/gob" "time" "unsafe" "gitlab.wow.st/gmp/persist" @@ -11,6 +12,7 @@ type Var_N persist.Var func New(name string, xs ..._T) *Var_N { var x _T + gob.Register(x) if len(xs) > 0 { x = xs[0] } diff --git a/test/basic/main.go b/test/basic/main.go index 72bb974..71fdf2f 100644 --- a/test/basic/main.go +++ b/test/basic/main.go @@ -9,29 +9,36 @@ import ( func main() { persist.Init() + x := persistInt("x",5) - var y1 mine1 = 6 - y2 := mine2{} - y1p := persistM1("y",y1) - y2p := persistM2("y",y2) - y3 := token.FileSet{} - y3p := persistM3("y",y3) - y4 := make(map[*token.FileSet]*token.File) - y4p := persistM4("y",y4) - y5 := make(map[*token.FileSet]*persist.Var) - y5p := persistM5("y",y5) - y6 := make(map[persist.Var]token.FileSet) - y6p := persistM6("y",y6) - _,_,_,_,_,_ = y1p, y2p, y3p, y4p, y5p, y6p fmt.Println(x) fmt.Println(x.Get()) x.Set(3) fmt.Println(x) + var y1 mine1 = 6 + y2 := mine2{} + y1p := persistM1("y1",y1) + y1 = y1p.Get() + y2p := persistM2("y2",y2) + y2 = y2p.Get() + y3 := token.FileSet{} + y3p := persistM3("y3",y3) + y3 = y3p.Get() + y4 := make(map[*token.FileSet]*token.File) + y4p := persistM4("y4",y4) + y4 = y4p.Get() + y5 := make(map[*token.FileSet]*persist.Var) + y5p := persistM5("y5",y5) + y5 = y5p.Get() + y6 := make(map[persist.Var]token.FileSet) + y6p := persistM6("y6",y6) + y6 = y6p.Get() + z := func(interface{}) { - _ = persistFloat("y",1.0) + _ = persistFloat("y7",1.0) } - z(persistString("name","ok")) + z(persistString("z","ok")) s := persistString("s","ok bye") fmt.Println(s) @@ -41,5 +48,6 @@ func main() { ts = s.Get() // this works _ = ts persist.Commit() + persist.Shutdown() }