Skip to content

Commit

Permalink
Remove code for encoding float32
Browse files Browse the repository at this point in the history
driver.Value values are always float64
  • Loading branch information
cbandy authored and johto committed Apr 18, 2015
1 parent e51fec1 commit 62de2aa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
4 changes: 0 additions & 4 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) [
switch v := x.(type) {
case int64:
return []byte(fmt.Sprintf("%d", v))
case float32:
return []byte(fmt.Sprintf("%.9f", v))
case float64:
return []byte(fmt.Sprintf("%.17f", v))
case []byte:
Expand Down Expand Up @@ -87,8 +85,6 @@ func appendEncodedText(parameterStatus *parameterStatus, buf []byte, x interface
switch v := x.(type) {
case int64:
return strconv.AppendInt(buf, v, 10)
case float32:
return strconv.AppendFloat(buf, float64(v), 'f', -1, 32)
case float64:
return strconv.AppendFloat(buf, v, 'f', -1, 64)
case []byte:
Expand Down
4 changes: 1 addition & 3 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,13 @@ func TestAppendEncodedText(t *testing.T) {

buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, int64(10))
buf = append(buf, '\t')
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, float32(42.0000000001))
buf = append(buf, '\t')
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, 42.0000000001)
buf = append(buf, '\t')
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, "hello\tworld")
buf = append(buf, '\t')
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, []byte{0, 128, 255})

if string(buf) != "10\t42\t42.0000000001\thello\\tworld\t\\\\x0080ff" {
if string(buf) != "10\t42.0000000001\thello\\tworld\t\\\\x0080ff" {
t.Fatal(string(buf))
}
}
Expand Down

0 comments on commit 62de2aa

Please sign in to comment.