Hi I want to ask some question regarding Golang echo.JSON() method. This line of code will return a virtualAccount struct
func (h virtualAccountsServiceHandler) Get(c echo.Context) (err error) {
virtualAccountID := c.Param("id")
virtualAccount, err := h.service.GetByID(c.Request().Context(), virtualAccountID)
if err != nil {
return
}
return c.JSON(http.StatusOK, virtualAccount)}
And this is the struct
type VirtualAccount struct {
ID string `json:"id"`
ExpirationDate time.Time `json:"expirationDate"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt time.Time `json:"-"`}
This function returns normally if the ExpirationDate is a normal date. But the problem arise when the data contains zero time.Time (0001-01-01 00:00:00.000 as stated here https://pkg.go.dev/time).
h.service.GetByID method will returns the date as it is (0001-01-01 00:00:00.000) but the echo.JSON will return empty string "" because now the time data has value of time.Time{}.
How to make echo.JSON returns it as it is (0001-01-01 00:00:00.000)?