Вот дата, с которой я отправляю (в необработанном тексте) режим из jsonified models.DateTimeField:
2019-05-07 16: 49: 47.351628 + 00: 00
Как я получу это на Голанге:
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"github.com/lib/pq"
)
type DataLink struct {
Created pq.NullTime `json:"created"`
}
type SendData struct {
Name string `json:"Name"`
}
func main() {
var reception = DataLink{}
var sendData = SendData{}
sendData.Name = "Melon"
url := "http://127.0.0.1:8309/getLinks/"
fmt.Println("URL:>", url)
js, err := json.Marshal(sendData)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(js))
req.Header.Set("X-Custom-Header", "myvalue")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
//fmt.Println("response Status:", resp.Status)
//fmt.Println("response Headers:", resp.Header)
body, _ := ioutil.ReadAll(resp.Body)
//fmt.Println("response Body:", string(body))
err = json.Unmarshal(body, &reception)
fmt.Println(reception.Created)
}
Но когда я печатаю свой объект, у меня есть:
{0001-01-01 00:00:00 +0000 UTC false}
Как конвертировать в идеале из поля времени django или с помощью манипуляции со строкой мое время даты, чтобы сделать его совместимым с go и pq.NullTime?
Все остальное работает (bool, int, float, string), но не дата ...