mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
26 lines
366 B
Go
26 lines
366 B
Go
package vartypes
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/elves/elvish/eval/types"
|
|
)
|
|
|
|
var errRoCannotBeSet = errors.New("read-only variable; cannot be set")
|
|
|
|
type ro struct {
|
|
value types.Value
|
|
}
|
|
|
|
func NewRo(v types.Value) Variable {
|
|
return ro{v}
|
|
}
|
|
|
|
func (rv ro) Set(val types.Value) error {
|
|
return errRoCannotBeSet
|
|
}
|
|
|
|
func (rv ro) Get() types.Value {
|
|
return rv.value
|
|
}
|