MCPcopy Index your code
hub / github.com/koding/kite / Square

Function Square

examples/math/math-kite/math.go:49–66  ·  view source on GitHub ↗
(r *kite.Request)

Source from the content-addressed store, hash-verified

47}
48
49func Square(r *kite.Request) (interface{}, error) {
50 // Unmarshal method arguments.
51 var params math.Request
52 if err := r.Args.One().Unmarshal(&params); err != nil {
53 return nil, err
54 }
55
56 result := params.Number * params.Number
57
58 fmt.Printf("Call received from '%s', sending result '%.0d' back\n", params.Name, result)
59
60 // Print a log on remote Kite.
61 // This message will be printed on client's console.
62 r.Client.Go("kite.log", fmt.Sprintf("Message from %s: \"You have requested square of %.0d\"", r.LocalKite.Kite().Name, params.Number))
63
64 // You can return anything as result, as long as it is JSON marshalable.
65 return result, nil
66}

Callers

nothing calls this directly

Calls 4

UnmarshalMethod · 0.80
OneMethod · 0.80
GoMethod · 0.80
KiteMethod · 0.45

Tested by

no test coverage detected