Golang错误"呼叫中没有足够的参数"

时间:2017-03-13 07:30:10

标签: elasticsearch go

我是golang的新手。尝试通过golang实现批量上传到Elasticsearch。我正在使用golang库 - > https://github.com/olivere/elastic用于与Elasticsearch进行通信。

另外,我尝试了一段示例代码,但却出现以下错误......

 listAccount(authToken: string): Observable<Account[]> {
   this.headers.set('Authorization', authToken);
   console.log(authToken, ')))))))))))))))))');
   returnthis.http.get(`${this.authApiUri}/${UrlConstant.ACCOUNT_LIST.replace('id' , '5682682637844480')}`, { headers: this.headers })
  ////////////////////////////////////////////////////////////////////////////////
  .do(data => {console.log(data)}) 
  //////////////////////////////////////////////////////////////////////////////////////
    .map(response => {
    console.log(response, 'LLLLLLLLLLLLLLL')
    let accounts: Account[] = [];
    response.json().accountList.forEach((accountResponse) => {
      let account = new Account(accountResponse.name , accountResponse.primaryEmailAddress, accountResponse.displayName);
      account.kazooAccountId = accountResponse.account_kazooAccountId;
      accounts.push(account);
    });
    return accounts;
  })
  .catch(this.handleError);
}

我的Golang代码(main.go)

suresh@BLR-245:~/Desktop/tools/golang/src$ go install github.com/crazyheart/elastic-bulk-upload
# github.com/crazyheart/elastic-bulk-upload
github.com/crazyheart/elastic-bulk-upload/main.go:29: not enough arguments in call to bulkRequest.Do
    have ()
    want ("golang.org/x/net/context".Context)
suresh@BLR-245:~/Desktop/tools/golang/src$ 

任何人,帮助我理解错误的含义&amp;怎么解决这些?

1 个答案:

答案 0 :(得分:1)

您需要将上下文传递给bulkRequest.Do()。

来自olivere / elastic Github页面(缩写);

// Create a context ctx := context.Background() bulkRequest.Do(ctx)

相关问题