37 lines
634 B
Go
37 lines
634 B
Go
|
package main
|
||
|
const template string = `package main
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
"unsafe"
|
||
|
"gitlab.wow.st/gmp/persist"
|
||
|
)
|
||
|
|
||
|
type Var_N persist.Var
|
||
|
|
||
|
func New(name string, xs ..._T) *Var_N {
|
||
|
var x _T
|
||
|
if len(xs) > 0 {
|
||
|
x = xs[0]
|
||
|
}
|
||
|
ptr := persist.New(name, x)
|
||
|
ret := (*Var_N)(unsafe.Pointer(ptr))
|
||
|
return ret
|
||
|
}
|
||
|
|
||
|
func (v *Var_N) Set(x _T) error {
|
||
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
||
|
return ptr.Set(x)
|
||
|
}
|
||
|
|
||
|
func (v *Var_N) Get(ts ...time.Time) _T {
|
||
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
||
|
return ptr.Get(ts...).(_T)
|
||
|
}
|
||
|
|
||
|
func (v *Var_N) History() ([]persist.TVar, error) {
|
||
|
ptr := (*persist.Var)(unsafe.Pointer(v))
|
||
|
return ptr.History()
|
||
|
}
|
||
|
`
|