Skip to content

Commit

Permalink
Check if ok when casting Scan src to string
Browse files Browse the repository at this point in the history
  • Loading branch information
theFong authored Jan 20, 2024
1 parent b1ce3af commit 96f251a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion amount.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ func (a Amount) Value() (driver.Value, error) {
// Allows scanning amounts from a PostgreSQL composite type.
func (a *Amount) Scan(src interface{}) error {
// Wire format: "(9.99,USD)".
input := src.(string)
input, ok := src.(string)
if !ok {
return fmt.Errorf("invalid src: %v", src)
}
if len(input) == 0 {
return nil
}
Expand Down

0 comments on commit 96f251a

Please sign in to comment.