In an attempt to handle null values when trying to input a struct of data to a database row (using goqu) I've defined a struct similar to
type datain struct {
id *float32 `db:"id"`
tempr *float32 `db:"temperature"`
}
When you defined a datain<\/code> variable without any initialization, the value of the
id<\/code> was nil, which means you couldn't de-reference it.
var datastruct datain
id := stringToFloat32("1234.4")
datastruct.id = &id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.