Register types with encoding/gob. Rewrite test/basic.
This commit is contained in:
parent
b880a5671d
commit
8f78a6c6d2
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
test/basic/basic
|
||||
test/basic/pgen.go
|
||||
test/basic/db
|
|
@ -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]
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user