This repository was archived by the owner on Jul 12, 2025. It is now read-only.

Description
When populating a pgtype.Numeric variable with Set() from a string that contains a number in scientific (exponential) notation, I get a "not a number" error.
This self-contained example program demonstrates the issue:
package main
import (
"fmt"
"strconv"
"github.com/jackc/pgtype"
)
func main() {
cases := []string{
"-1e+1",
"4.3e-5",
"4.3e-05",
"4.3E-5",
"0e0",
}
for _, numStr := range cases {
numFloat, err := strconv.ParseFloat(numStr, 64)
if err != nil {
fmt.Printf("error parsing float: %v\n", err)
continue
}
fmt.Printf("parsed float: %v\n", numFloat)
var numField pgtype.Numeric
err = numField.Set(numStr)
if err != nil {
fmt.Printf("error setting field: %v\n", err)
continue
}
fmt.Printf("field set: %v\n", numField)
}
}
I'd have expected that all of these example cases are recognized and parsed correctly.