Skip to content

Commit

Permalink
style fixes for a few recent PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoiron committed Dec 2, 2016
1 parent 6708aed commit 1a35d27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
}
Expand All @@ -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)
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}

0 comments on commit 1a35d27

Please sign in to comment.