Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created June 4, 2019 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eminetto/d796f31f97d5086115bfc4c003a3f58b to your computer and use it in GitHub Desktop.
Save eminetto/d796f31f97d5086115bfc4c003a3f58b to your computer and use it in GitHub Desktop.
package ecommerce
import (
"strconv"
)
type order struct {
pid productID
cid customerID
}
type productID int64
// some methods on productID type
type customerID int64
// some methods on customerID type
type orderID int64
func (oid orderID) String() string {
return strconv.FormatInt(int64(oid), 10)
}
// some other methods on orderID type
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