3
にtime.TimeにNULL解析行く - 私はtime.Time型を持つ構造体にキャストしています構造体
t2 := time.Now()
format := "2006-01-02 15:04:05"
theTime, _ := time.Parse(format, t2.Format(format))
しかし、時々私はtime.Timeフィールドを設定する必要はありません。どのようにgo/mysql dbドライバでこれを定義しますか?
app_history := &models.AppsHistoryInsert{
AppId: response.SetAppData[0].Id,
LiveDate: &theTime,
}
基本的に、私は
if(x == true) {
include time
}
else {
don't include time.
}
をしたい私は、構造体宣言自体の周りif
をやってLiveDate
フィールドを除外しようとしたが、私はあなたが定義する必要がcontrollers/apps.go:1068: undefined: app_history
また、実際にはそのinitよりも多くの場合があります。今のようにしますが、 "LiveDate"を除外してから、最初の構造体を作成した後にx {app_history.LiveDate =&theTime} –