You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
7 years ago | |
---|---|---|
LICENCE | 7 years ago | |
README.md | 7 years ago | |
caller.go | 7 years ago | |
caller_test.go | 7 years ago |
README.md
Caller
Package caller is used to dynamically call functions with data unmarshalled into the functions' first argument. Its main purpose is to hide common unmarshalling code from each function implementation thus reducing boilerplate and making package interaction code sexier.
Caller abstracts away the process of unmarshaling data before processing.
type PriceUpdate struct {
Product string `json:"product"`
Amount float32 `json:"amount"`
}
func PriceUpdatePrinter(p PriceUpdate) {
log.Printf("Price for %q is now $%.2f", p.Product, p.Amount)
}
// Error handling is skipped for clarity
func main() {
printer, _ := caller.New(PriceUpdatePrinter)
_ = printer.Call([]byte(`{"product": "Paperclip", "amount": 0.01}`))
}