client/client.go
func (c *Client) pageOverJob(rowCount int, jobRef *bigquery.JobReference, pageToken string, resultChan chan [][]interface{}, headersChan chan []string) error {
	service, err := c.connect()
	if err != nil {
		return err
	}

	qrc := service.Jobs.GetQueryResults(jobRef.ProjectId, jobRef.JobId)
	if len(pageToken) > 0 {
		qrc.PageToken(pageToken)
	}

	qr, err := qrc.Do()
	if err != nil {
		c.printDebug("Error loading additional data: ", err)
		close(resultChan)
		return err
	}

	if qr.JobComplete {
		c.printDebug("qr.JobComplete")
		headers, rows := c.headersAndRows(qr.Schema, qr.Rows)
		if headersChan != nil {
			headersChan <- headers
			close(headersChan)
		}

		// send back the rows we got
		c.printDebug("sending rows")
		resultChan <- rows
		rowCount = rowCount + len(rows)
		c.printDebug("Total rows: ", rowCount)
	}

	if qr.TotalRows > uint64(rowCount) || !qr.JobComplete {
		c.printDebug("!qr.JobComplete")
		if qr.JobReference == nil {
			c.pageOverJob(rowCount, jobRef, pageToken, resultChan, headersChan)
		} else {
			c.pageOverJob(rowCount, qr.JobReference, qr.PageToken, resultChan, nil)
		}
	} else {
		close(resultChan)
		return nil
	}

	return nil
}
func (c *Client) pageOverJob(rowCount int, jobRef *bigquery.JobReference, pageToken string, resultChan chan [][]interface{}, headersChan chan []string) error {
	service, err := c.connect()
	if err != nil {
		return err
	}

	qrc := service.Jobs.GetQueryResults(jobRef.ProjectId, jobRef.JobId)
	if len(pageToken) > 0 {
		qrc.PageToken(pageToken)
	}

	qr, err := qrc.Do()
	if err != nil {
		c.printDebug("Error loading additional data: ", err)
		close(resultChan)
		return err
	}

	if qr.JobComplete {
		c.printDebug("qr.JobComplete")
		headers, rows := c.headersAndRows(qr.Schema, qr.Rows)
		if headersChan != nil {
			headersChan <- headers
			close(headersChan)
		}

		// send back the rows we got
		c.printDebug("sending rows")
		resultChan <- rows
		rowCount = rowCount + len(rows)
		c.printDebug("Total rows: ", rowCount)
	}

	if qr.TotalRows > uint64(rowCount) || !qr.JobComplete {
		c.printDebug("!qr.JobComplete")
		if qr.JobReference == nil {
			c.pageOverJob(rowCount, jobRef, pageToken, resultChan, headersChan)
		} else {
			c.pageOverJob(rowCount, qr.JobReference, qr.PageToken, resultChan, nil)
		}
	} else {
		close(resultChan)
		return nil
	}

	return nil
}
// pageOverJob loads results for the given job reference and if the total results has not been hit continues to load recursively