A simple main.go
that creates a sheets service to append data to a spreadsheet.
This main.go
was created using the sheets package for Golang.
For more information about the Google Sheets API
, you can check out the official documentation.
This application uses a service account to authenticate with the Google Sheets API
because I found it easier to use. However,
if you don't want to use a service account, you can use OAuth2.0
instead, but you will need to change the code to use
the OAuth2.0
flow. You can find more information about this in the
Google Sheets API quickstart.
In both cases, you will need to enable the Google Sheets API
in your project (see the quickstart guide for more information)
and share the spreadsheet with the service account email address or the email address of the account you want to use.
A list of common terms used in the Sheets API such as spreadsheetId
and sheetId
can be found
here.
Here is an example of the expected result:
Just in case, the "INSERT_ROWS" option gives us the advantage of keeping the checkbox when appending new rows.