Skip to content

Instantly share code, notes, and snippets.

@CharlesWinter
Created January 22, 2021 15:16
Show Gist options
  • Save CharlesWinter/e4eab82562d31aef8b6d7788c54eb83c to your computer and use it in GitHub Desktop.
Save CharlesWinter/e4eab82562d31aef8b6d7788c54eb83c to your computer and use it in GitHub Desktop.
The get_customer.go File
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