ningyougang commented on code in PR #170:
URL: 
https://github.com/apache/openwhisk-runtime-go/pull/170#discussion_r937318974


##########
tests/src/test/scala/runtime/actionContainers/ActionLoopGoContainerTests.scala:
##########
@@ -135,4 +135,51 @@ abstract class ActionLoopGoContainerTests
       c.run(helloMsg()) should be(okMsg("hello-Hello", "Hello, Demo!"))
     }
   }
+
+  it should "support return array result" in {
+    val helloArrayGo = {
+      s"""
+         |package main
+         |
+         |func Main(obj map[string]interface{}) []interface{} {
+         |    result := []interface{}{"a", "b"}
+         |    return result
+         |}
+         |
+       """.stripMargin
+    }
+    val src = ExeBuilder.mkBase64SrcZip(
+      Seq(
+        Seq(s"main.go") -> helloArrayGo
+      ))
+    withActionLoopContainer { c =>
+      c.init(initPayload(src))._1 shouldBe (200)
+      val result = c.runForJsArray(JsObject())
+      result._1 shouldBe (200)
+      result._2 shouldBe Some(JsArray(JsString("a"), JsString("b")))
+    }
+  }
+
+  it should "support array as input param" in {
+    val helloArrayGo = {
+      s"""
+         |package main
+         |
+         |func Main(obj []interface{}) []interface{} {

Review Comment:
   Use reflect to invoke the Main, e.g.
   * pass `object parameter`
   
      
https://github.com/apache/openwhisk-runtime-go/pull/170/files#diff-8f7cd20b9f7340baadcd155468f78cad8ba149c8d97c6e068a830daf1c210320R110
   
   * pass `array parameter`
   
     
https://github.com/apache/openwhisk-runtime-go/pull/170/files#diff-8f7cd20b9f7340baadcd155468f78cad8ba149c8d97c6e068a830daf1c210320R114
   
   Can't invoke the Main directly due to compile error, should use reflect to 
invoke.
   
   Btw, why can invoke Main direclty before? because the input param's data 
type is explicit.
   But in this pr, the data type supports 2 data types, so should use reflect 
to invoke it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to