diff --git a/helper/throw.process.go b/helper/control.process.go similarity index 71% rename from helper/throw.process.go rename to helper/control.process.go index 18740a57..f1183815 100644 --- a/helper/throw.process.go +++ b/helper/control.process.go @@ -5,6 +5,11 @@ import ( "github.com/yaoapp/kun/exception" ) +// ProcessReturn xiang.helper.Return 返回数值 +func ProcessReturn(process *gou.Process) interface{} { + return process.Args +} + // ProcessThrow xiang.helper.Throw 抛出异常 func ProcessThrow(process *gou.Process) interface{} { process.ValidateArgNums(2) diff --git a/helper/throw_test.go b/helper/control_test.go similarity index 63% rename from helper/throw_test.go rename to helper/control_test.go index 74eb4e30..78881ff1 100644 --- a/helper/throw_test.go +++ b/helper/control_test.go @@ -14,3 +14,9 @@ func TestProcessThrow(t *testing.T) { gou.NewProcess("xiang.helper.Throw", "Someting error", 500).Run() }) } + +func TestProcessReturn(t *testing.T) { + v := gou.NewProcess("xiang.helper.Return", "hello", "world").Run().([]interface{}) + assert.Equal(t, "hello", v[0]) + assert.Equal(t, "world", v[1]) +} diff --git a/helper/process.go b/helper/process.go index aa0e0c4d..0033bb14 100644 --- a/helper/process.go +++ b/helper/process.go @@ -47,6 +47,7 @@ func init() { gou.RegisterProcessHandler("xiang.helper.Print", ProcessPrint) gou.RegisterProcessHandler("xiang.helper.Throw", ProcessThrow) + gou.RegisterProcessHandler("xiang.helper.Return", ProcessReturn) }