Skip to content

Commit

Permalink
ensure existence of record array
Browse files Browse the repository at this point in the history
  • Loading branch information
audibleblink committed Aug 21, 2020
1 parent 7598514 commit 3d162d3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func parameterize(q string, fields map[string]string) *bigquery.Query {
}

func queryRecords(query *bigquery.Query) (records []*record, err error) {
records = make([]*record, 0)
ctx := context.Background()
results, err := query.Read(ctx)
if err != nil {
Expand All @@ -228,9 +229,6 @@ func queryRecords(query *bigquery.Query) (records []*record, err error) {
}

func resultWriter(w http.ResponseWriter, records []*record) {
if records == nil{
records = make([]*record, 0)
}
resultJson, err := json.Marshal(records)
if err != nil {
JSONError(w, err, http.StatusInternalServerError)
Expand Down

0 comments on commit 3d162d3

Please sign in to comment.