1
0
Fork 0
Making JSON parsing fancier by making it less performant
Go to file
Gregory Eremin 069b5b865e
Initial commit
2016-07-26 21:56:50 +02:00
README.md Initial commit 2016-07-26 21:56:50 +02:00
caller.go Initial commit 2016-07-26 21:56:50 +02:00
caller_test.go Initial commit 2016-07-26 21:56:50 +02:00

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