Timestamp is a helper function to convert timestamp strings to pgtype.Timestamp instances. If the string cannot be converted, this function will panic.
(timestampStr string)
| 864 | // Timestamp is a helper function to convert timestamp strings to pgtype.Timestamp instances. If |
| 865 | // the string cannot be converted, this function will panic. |
| 866 | func Timestamp(timestampStr string) (ret pgtype.Timestamp) { |
| 867 | t, err := time.Parse("2006-01-02 15:04:05", timestampStr) |
| 868 | if err != nil { |
| 869 | panic("invalid timestamp format: " + err.Error()) |
| 870 | } |
| 871 | if err := ret.Scan(t); err != nil { |
| 872 | panic("failed to set pgtype.Timestamp: " + err.Error()) |
| 873 | } |
| 874 | return ret |
| 875 | } |
| 876 | |
| 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. |
no test coverage detected