Initial commit

This commit is contained in:
2014-08-24 19:56:55 +07:00
commit 509f281f72
11 changed files with 337 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package power
import (
"code.google.com/p/go.net/context"
)
type (
PowerResult struct {
Num int
Power int
Result int
}
)
func Power2(ctx context.Context) context.Context {
v := ctx.Value("num").(int)
res := PowerResult{Num: v, Power: 2, Result: v * v}
ctx = context.WithValue(ctx, "power_result", res)
return ctx
}
func Power3(ctx context.Context) context.Context {
v := ctx.Value("num").(int)
res := PowerResult{Num: v, Power: 3, Result: v * v * v}
ctx = context.WithValue(ctx, "power_result", res)
return ctx
}
func Power5(ctx context.Context) context.Context {
v := ctx.Value("num").(int)
res := PowerResult{Num: v, Power: 5, Result: v * v * v * v * v}
ctx = context.WithValue(ctx, "power_result", res)
return ctx
}