..
2015-10-14 00:08:45 +03:00
2015-10-14 00:08:45 +03:00
2015-10-14 00:08:45 +03:00

Caller

Package caller is used to dynamicly call functions with data unmarshalled into the functions' first argument. It's main purpose is to hide common unmarshalling code from each function's implementation thus reducing boilerplate and making the code sexier.

Documentation

package main

import (
    "github.com/localhots/uberdaemon/caller"
)

type message struct {
    Title string `json:"title"`
    Body  string `json:"body"`
}

func processMessage(m message) {
    fmt.Printf("Title: %s\nBody: %s\n", m.Title, m.Body)
}

func main() {
    c, _ := caller.New(processMessage)
    c.Call(`{"title": "Hello", "body": "World"}`)
}