Skip to content

Commit

Permalink
type alias instead of struct for NullValue
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed May 4, 2015
1 parent 2a0b42e commit 9d284a9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions value.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,44 +141,46 @@ func NewValue(v interface{}) Value {
// NullValue is an empty value.
type NullValue struct{}

var nullValue NullValue

// NewNullValue generates a NullValue instance.
func NewNullValue() *NullValue {
return &NullValue{}
func NewNullValue() NullValue {
return nullValue
}

func (vl *NullValue) estimateSize() int {
func (vl NullValue) estimateSize() int {
return 0
}

func (vl *NullValue) write(buffer []byte, offset int) (int, error) {
func (vl NullValue) write(buffer []byte, offset int) (int, error) {
return 0, nil
}

func (vl *NullValue) pack(packer *packer) error {
func (vl NullValue) pack(packer *packer) error {
packer.PackNil()
return nil
}

// GetType returns wire protocol value type.
func (vl *NullValue) GetType() int {
func (vl NullValue) GetType() int {
return ParticleType.NULL
}

// GetObject returns original value as an interface{}.
func (vl *NullValue) GetObject() interface{} {
func (vl NullValue) GetObject() interface{} {
return nil
}

// func (vl *NullValue) GetLuaValue() LuaValue {
// func (vl NullValue) GetLuaValue() LuaValue {
// return LuaNil.NIL
// }

func (vl *NullValue) reader() io.Reader {
func (vl NullValue) reader() io.Reader {
return nil
}

// String implements Stringer interface.
func (vl *NullValue) String() string {
func (vl NullValue) String() string {
return ""
}

Expand Down

0 comments on commit 9d284a9

Please sign in to comment.