Skip to content

Instantly share code, notes, and snippets.

@polyglotdev
Created April 22, 2024 18:34
Show Gist options
  • Save polyglotdev/4ea9650010e097bc9356451215406d64 to your computer and use it in GitHub Desktop.
Save polyglotdev/4ea9650010e097bc9356451215406d64 to your computer and use it in GitHub Desktop.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment