Skip to content

Instantly share code, notes, and snippets.

@kyleconroy
Last active January 18, 2024 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleconroy/11e58b9480f97d838cc04793dc07005a to your computer and use it in GitHub Desktop.
Save kyleconroy/11e58b9480f97d838cc04793dc07005a to your computer and use it in GitHub Desktop.
Numerics in pgx/v5
package main
import (
"fmt"
"github.com/jackc/pgx/v5/pgtype"
)
func main() {
var num pgtype.Numeric
if err := num.Scan(updateCustomerObj.DiscountPercentage); err != nil {
fmt.Println(err)
return
}
sqlc.UpdateCustomersParams{
SetDiscountPercentage: !(updateCustomerObj.DiscountPercentage == 0),
DiscountPercentage: *num
}
fmt.Printf("output: %s", output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment