Created
September 27, 2017 18:03
-
-
Save funkeyfreak/0edf1404eae96cd20df362af151c3b66 to your computer and use it in GitHub Desktop.
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 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