Closed PanicIsReal closed 8 years ago
I have been going over and making structs for all my data because dealing with interface values is getting annoying, so I have:
package model import "time" // User database struct type User struct { ID string `gorethink:"id" json:"id"` CreatedAt time.Time `gorethink:"created_at" json:"created_at"` UpdatedAt time.Time `gorethink:"updated_at" json:"updated_at"` Username string `gorethink:"username" json:"username"` Email string `gorethink:"email" json:"email"` ProfileURL string `gorethink:"profileURL" json:"profileURL"` Firstname string `gorethink:"first_name" json:"first_name"` Lastname string `gorethink:"last_name" json:"last_name"` Bio string `gorethink:"bio" json:"bio"` Identifier string `gorethink:"identifier" json:"identifier"` SteamID string `gorethink:"steamID" json:"steamID"` CEVO string `gorethink:"cevo" json:"cevo"` ESEA string `gorethink:"ESEA" json:"esea"` Wins int `gorethink:"wins" json:"wins"` Rank int `gorethink:"rank" json:"rank"` ComFriendly int `gorethink:"com_friendly" json:"com_friendly"` ComLeader int `gorethink:"com_leader" json:"com_leader"` ComTeaching int `gorethink:"com_teaching" json:"com_teaching"` QueueSettings QueueSettings `gorethink:"queue_settings" json:"queue_settings"` } // QueueSettings is the Users settings for entering the queue type QueueSettings struct { Microphone int `gorethink:"microphone" json:"microphone"` RankTollerance int `gorethink:"rank_tollerance" json:"rank_tollerance"` Type string `gorethink:"type" json:"type"` }
All the data gets saved fine, but the id is "" in the database, how can I make it so that the id is still generated?
id
""
Seemed adding ,omitempty for the id tag seemed to allow it to create it just fine, I'll leave this here for future knowledge
,omitempty
Glad you fixed this :+1:
I have been going over and making structs for all my data because dealing with interface values is getting annoying, so I have:
All the data gets saved fine, but the
id
is""
in the database, how can I make it so that theid
is still generated?