【问题标题】:Calling Apps Script API function from Golang with Parameters?使用参数从 Golang 调用 Apps Script API 函数?
【发布时间】:2018-08-17 06:22:13
【问题描述】:

我想从 Golang 调用 Apps Script 函数。

我可以从 Golang 发送参数,但不能使其在 runMyFunction 中工作。如果我添加return myParameter; - 我可以看到参数 我正在传递,但在 SQL 中使用它到 BigQuery 不起作用。我收到undefined

var sql = ' SELECT column1, column2 ' +
  ' FROM  dataset.mytable WHERE SUBSTR ( column1) = "'
+ myParameter + '" ;'

我的应用程序脚本功能:

function runMyFunction(myParameter) {
...
return myParameter;
}

在 Golang 中,调用 runMyFunction

type Message struct {
    myParameter string
}
m := Message{"1234"}
a := make([]interface{}, 1)
a[0] = m
req := script.ExecutionRequest{Function: "runMyFunction",
    Parameters: a,
    DevMode:    true}

// Make the API request.
resp, err := srv.Scripts.Run(scriptID, &req).Do()

【问题讨论】:

    标签: go google-apps-script google-bigquery


    【解决方案1】:

    其实这是正确的解决方案:

    a := []interface{}{"1234"}
    req := script.ExecutionRequest{Function: "runMyFunction",
    Parameters: a,
    DevMode:    true}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 2021-06-08
      • 2021-01-10
      • 2016-08-17
      相关资源
      最近更新 更多