Date is a helper function to convert date strings to pgtype.Date instances. If the string cannot be converted, this function will panic.
(dateStr string)
| 877 | // Date is a helper function to convert date strings to pgtype.Date instances. If the string |
| 878 | // cannot be converted, this function will panic. |
| 879 | func Date(dateStr string) (d pgtype.Date) { |
| 880 | t, err := time.Parse("2006-01-02", dateStr) |
| 881 | if err != nil { |
| 882 | panic("invalid date format: " + err.Error()) |
| 883 | } |
| 884 | if err := d.Scan(t); err != nil { |
| 885 | panic("failed to set pgtype.Date: " + err.Error()) |
| 886 | } |
| 887 | return d |
| 888 | } |
| 889 | |
| 890 | // UUID is a helper function to convert UUID strings to pgtype.UUID instances. If the string |
| 891 | // cannot be converted, this function will panic. |
no test coverage detected