Created
April 22, 2024 18:34
-
-
Save polyglotdev/4ea9650010e097bc9356451215406d64 to your computer and use it in GitHub Desktop.
How do we know that the return type was what it is?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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