elvish/eval/shared.go
Qi Xiao 92fb6e5161 Support shared variable.
This fixes #15. Only string is supported ATM.
2016-02-26 04:05:47 +01:00

20 lines
362 B
Go

package eval
import "github.com/elves/elvish/store"
type sharedVariable struct {
store *store.Store
name string
}
func (sv sharedVariable) Set(val Value) {
err := sv.store.SetSharedVar(sv.name, ToString(val))
maybeThrow(err)
}
func (sv sharedVariable) Get() Value {
value, err := sv.store.GetSharedVar(sv.name)
maybeThrow(err)
return String(value)
}