gvar.Set方法返回旧的变量值

This commit is contained in:
john
2018-10-25 12:10:05 +08:00
parent e0c93a9429
commit 0d7130ee48

View File

@ -30,12 +30,14 @@ func New(value interface{}, safe...bool) *Var {
return v
}
func (v *Var) Set(value interface{}) {
func (v *Var) Set(value interface{}) (old interface{}) {
if v.safe {
v.value.(*gtype.Interface).Set(value)
old = v.value.(*gtype.Interface).Set(value)
} else {
old = v.value
v.value = value
}
return
}
func (v *Var) Val() interface{} {