build: add example usage in cmd/main.go and correct build script

This commit is contained in:
Mike Berezin
2021-01-29 13:21:39 +03:00
committed by mehanizm
parent 420d81196b
commit 68bcb7f9f7
2 changed files with 46 additions and 2 deletions

View File

@@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.13 - name: Set up Go 1.15
uses: actions/setup-go@v1 uses: actions/setup-go@v1
with: with:
go-version: 1.13 go-version: 1.15
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory

44
cmd/main.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"fmt"
"github.com/mehanizm/airtable"
)
const (
airtableAPIKey = "xxx"
airtableDBName = "xxx"
airtableTableName = "xxx"
)
func main() {
airtableClient := airtable.NewClient(airtableAPIKey)
airtableTable := airtableClient.GetTable(airtableDBName, airtableTableName)
offset := ""
for {
records, err := airtableTable.GetRecords().
WithFilterFormula("NOT({SomeBoolColumn})").
ReturnFields("Column1", "Column2", "Column3", "Column4").
MaxRecords(100).
PageSize(10).
WithOffset(offset).
Do()
if err != nil {
panic(err)
}
for recordNum, record := range records.Records {
fmt.Println("====iteration====")
fmt.Println(recordNum, record)
}
offset = records.Offset
if offset == "" {
break
}
}
}