Created
January 22, 2021 15:16
-
-
Save CharlesWinter/e4eab82562d31aef8b6d7788c54eb83c to your computer and use it in GitHub Desktop.
The get_customer.go File
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
package customers | |
import "github.com/example/go-abstractions/entities" | |
// representation of a fictional database customer. | |
type customerData struct { | |
ID uint `db:"id"` | |
FirstName string `db:"name"` | |
Postcode string `db:"postcode"` | |
} | |
func (r *Repository) GetCustomer(customerID uint) (entities.Customer, error) { | |
customerData, err := r.somethingToAccessTheDB.GetCustomer(customerID) | |
return entities.Customer{ | |
ID: customerData.ID, | |
FirstName: customerData.FirstName, | |
Postcode: customerData.Postcode, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment