Skip to content

Instantly share code, notes, and snippets.

View polyglotdev's full-sized avatar
🔮
Focusing

Dom Hallan polyglotdev

🔮
Focusing
View GitHub Profile
@polyglotdev
polyglotdev / models.go
Created April 22, 2024 18:34
How do we know that the return type was what it is?
func GetEventByID(id int64) (*Event, error) {
query := `SELECT * FROM events WHERE id = ?`
row := db.DB.QueryRow(query, id)
var event Event
err := row.Scan(&event.ID, &event.Name, &event.Description, &event.Location, &event.DateTime, &event.UserID)
if err != nil {
return nil, err
}
return &event, nil