32 lines
458 B
Go
32 lines
458 B
Go
package types
|
|
|
|
type ValueType byte
|
|
|
|
const (
|
|
TypeNull ValueType = iota
|
|
TypeNumber
|
|
TypeString
|
|
TypeBoolean
|
|
)
|
|
|
|
type Value struct {
|
|
Type ValueType
|
|
Data any
|
|
}
|
|
|
|
func NewString(s string) Value {
|
|
return Value{Type: TypeString, Data: s}
|
|
}
|
|
|
|
func NewNumber(n float64) Value {
|
|
return Value{Type: TypeNumber, Data: n}
|
|
}
|
|
|
|
func NewBoolean(b bool) Value {
|
|
return Value{Type: TypeBoolean, Data: b}
|
|
}
|
|
|
|
func NewNull() Value {
|
|
return Value{Type: TypeNull, Data: nil}
|
|
}
|