Created
June 4, 2019 02:15
-
-
Save eminetto/2ccaff86bb0c1eff86238eb724b1fd31 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ecommerce | |
import ( | |
"strconv" | |
) | |
type order struct { | |
pid productID | |
cid customerID | |
} | |
type productID struct { | |
id int64 | |
} | |
// some methods on productID struct | |
type customerID struct { | |
id int64 | |
} | |
// some methods on customerID struct | |
type orderID struct { | |
id int64 | |
} | |
func (oid orderID) String() string { | |
return strconv.FormatInt(oid.id, 10) | |
} | |
// some other methods on orderID struct | |
func CreateOrder(pid int64, cid int64) order { | |
return order{ | |
pid: productID{pid}, cid: customerID{cid}, | |
} | |
} | |
func (o order) Submit() (orderID, error) { | |
// do some logic | |
return orderId{int64(3252345234)}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment