Skip to content

Instantly share code, notes, and snippets.

@funkeyfreak
Created September 27, 2017 18:03
Show Gist options
  • Save funkeyfreak/0edf1404eae96cd20df362af151c3b66 to your computer and use it in GitHub Desktop.
Save funkeyfreak/0edf1404eae96cd20df362af151c3b66 to your computer and use it in GitHub Desktop.
package example
import "fmt"
type Resource interface {
Href() string
}
type Customer struct {
Id UUID.uuid
Name string
}
func (c Customer) Href() {
return fmt.Sprintf("https://%s/%s", "example.com", c.Id)
}
type Account struct {
Id UUID.uuid
UserHref Resource
}
func (a *Account) Build(c Customer) error{
if c != nil {
return errors.New("Cannot do this without a user")
}
a.UserHref = c
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment