persist/test/basic/main.go

56 lines
996 B
Go
Raw Normal View History

2018-08-03 15:08:30 -04:00
package main
//go:generate pgen
import (
"fmt"
gtoken "go/token"
2018-08-03 15:08:30 -04:00
"gitlab.wow.st/gmp/persist"
)
func main() {
persist.Init()
2018-08-03 15:08:30 -04:00
x := persistInt("x",5)
fmt.Println(x)
fmt.Println(x.Get())
x.Set(3)
fmt.Println(x)
2018-08-03 15:08:30 -04:00
var y1 mine1 = 6
y2 := mine2{}
y1p := persistM1("y1",y1)
y1 = y1p.Get() // confirm types match
y2p := persistM2("y2",y2)
y2 = y2p.Get()
y3 := gtoken.FileSet{}
y3p := persistM3("y3",y3)
y3 = y3p.Get()
y4 := make(map[*gtoken.FileSet]*gtoken.File)
y4p := persistM4("y4",y4)
y4 = y4p.Get()
y5 := make(map[*gtoken.FileSet]*persist.Var)
y5p := persistM5("y5",y5)
y5 = y5p.Get()
y6 := make(map[persist.Var]gtoken.FileSet)
y6p := persistM6("y6",y6)
y6 = y6p.Get()
y7p := persistIntArray("y7",[]int{1,2,3})
_ = y7p
2018-08-03 15:08:30 -04:00
z := func(interface{}) {
_ = persistFloat("y7",1.0)
2018-08-03 15:08:30 -04:00
}
z(persistString("z","ok"))
2018-08-03 15:08:30 -04:00
s := persistString("s","ok bye")
fmt.Println(s)
s.Set("one two")
var ts string
ts = s.Get() // this works
_ = ts
persist.Commit()
persist.Shutdown()
2018-08-03 15:08:30 -04:00
}