I'm not quite understanding how the google sheets api for go works.
What I want to do is delete sheet at location 0 from a spreadsheet. Here is the code snippit for the request that doesn't work right now.
rb2 := &sheets.BatchUpdateSpreadsheetRequest{
Requests: requests,
}
resp2, err := srv.Spreadsheets.BatchUpdate(destinationSpreadsheetId, rb3).Do()
What I thought I'd do is create request
before making the request body on line 1 above.
ds := &sheets.DeleteSheetRequest{
SheetId: int64(0),
}
deleteSheet := &sheets.DeleteSheet{
DeleteSheetRequest: ds,
}
requests := []*sheets.Request{
DeleteSheet: deleteSheet,
}
If I try to build it, the compiler will error,
sheets\sheets.go:118:19: undefined: sheets.DeleteSheet
sheets\sheets.go:123:4: undefined: DeleteSheet
I was trying to follow the sheets manual, https://godoc.org/google.golang.org/api/sheets/v4#BatchUpdateSpreadsheetRequest
The fix:
deleteSheetRequest := &sheets.DeleteSheetRequest{
SheetId: 0,
}
requests := []*sheets.Request{
{DeleteSheet: deleteSheetRequest},
}
rb3 := &sheets.BatchUpdateSpreadsheetRequest{
Requests: requests,
// TODO: Add desired fields of the request body.
}
resp2, err := srv.Spreadsheets.BatchUpdate(destinationSpreadsheetId, rb3).Do()
if err != nil {
log.Fatal(err)
}
fmt.Println(resp2)
@tehhowch, thanks for the help. I fixed that and then I eventually realized after looking at the code that the []*sheets.Request was missing array brackets. Duh.