diff --git a/types/types.go b/types/types.go index 2c90b4cf..7f378c66 100644 --- a/types/types.go +++ b/types/types.go @@ -57,12 +57,12 @@ func (g *GzippedText) Scan(src interface{}) error { // implements `Unmarshal`, which unmarshals the json within to an interface{} type JSONText json.RawMessage -var _EMPTY_JSON = JSONText("{}") +var emptyJSON = JSONText("{}") // MarshalJSON returns the *j as the JSON encoding of j. func (j *JSONText) MarshalJSON() ([]byte, error) { if len(*j) == 0 { - *j = _EMPTY_JSON + *j = emptyJSON } return *j, nil } @@ -95,12 +95,12 @@ func (j *JSONText) Scan(src interface{}) error { source = []byte(t) case []byte: if len(t) == 0 { - source = _EMPTY_JSON + source = emptyJSON } else { source = t } case nil: - *j = _EMPTY_JSON + *j = emptyJSON default: return errors.New("Incompatible type for JSONText") } @@ -111,7 +111,7 @@ func (j *JSONText) Scan(src interface{}) error { // Unmarshal unmarshal's the json in j to v, as in json.Unmarshal. func (j *JSONText) Unmarshal(v interface{}) error { if len(*j) == 0 { - *j = _EMPTY_JSON + *j = emptyJSON } return json.Unmarshal([]byte(*j), v) } @@ -132,7 +132,7 @@ type NullJSONText struct { // Scan implements the Scanner interface. func (n *NullJSONText) Scan(value interface{}) error { if value == nil { - n.JSONText, n.Valid = _EMPTY_JSON, false + n.JSONText, n.Valid = emptyJSON, false return nil } n.Valid = true diff --git a/types/types_test.go b/types/types_test.go index cbe200c3..29813d1e 100644 --- a/types/types_test.go +++ b/types/types_test.go @@ -107,7 +107,7 @@ func TestBitBool(t *testing.T) { t.Errorf("Was not expecting an error") } if !b { - t.Errorf("Was expecting the bool we sent in (true), got %b", b) + t.Errorf("Was expecting the bool we sent in (true), got %v", b) } // Test false value @@ -122,6 +122,6 @@ func TestBitBool(t *testing.T) { t.Errorf("Was not expecting an error") } if b { - t.Errorf("Was expecting the bool we sent in (false), got %b", b) + t.Errorf("Was expecting the bool we sent in (false), got %v", b) } }