1
0
Fork 0
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.
Gregory Eremin f9382cc766
Add licence
7 years ago
LICENCE Add licence 7 years ago
README.md Initial commit 7 years ago
caller.go Initial commit 7 years ago
caller_test.go Initial commit 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.

Documentation

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}`))
}