Skip to content

Commit b7d6287

Browse files
committed
Remove code for encoding float32
driver.Value values are always float64
1 parent 4645bc4 commit b7d6287

2 files changed

Lines changed: 1 addition & 7 deletions

File tree

encode.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) [
1818
switch v := x.(type) {
1919
case int64:
2020
return []byte(fmt.Sprintf("%d", v))
21-
case float32:
22-
return []byte(fmt.Sprintf("%.9f", v))
2321
case float64:
2422
return []byte(fmt.Sprintf("%.17f", v))
2523
case []byte:
@@ -87,8 +85,6 @@ func appendEncodedText(parameterStatus *parameterStatus, buf []byte, x interface
8785
switch v := x.(type) {
8886
case int64:
8987
return strconv.AppendInt(buf, v, 10)
90-
case float32:
91-
return strconv.AppendFloat(buf, float64(v), 'f', -1, 32)
9288
case float64:
9389
return strconv.AppendFloat(buf, v, 'f', -1, 64)
9490
case []byte:

encode_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,13 @@ func TestAppendEncodedText(t *testing.T) {
510510

511511
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, int64(10))
512512
buf = append(buf, '\t')
513-
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, float32(42.0000000001))
514-
buf = append(buf, '\t')
515513
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, 42.0000000001)
516514
buf = append(buf, '\t')
517515
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, "hello\tworld")
518516
buf = append(buf, '\t')
519517
buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, []byte{0, 128, 255})
520518

521-
if string(buf) != "10\t42\t42.0000000001\thello\\tworld\t\\\\x0080ff" {
519+
if string(buf) != "10\t42.0000000001\thello\\tworld\t\\\\x0080ff" {
522520
t.Fatal(string(buf))
523521
}
524522
}

0 commit comments

Comments
 (0)