func()

in tools/mconnect/commands/export/export.go [146:171]


func (c *castExporter) createDataset(ctx context.Context, client *bq.Client) (bool, error) {
	dataset := client.Dataset(c.datasetID)
	metadata, err := dataset.Metadata(ctx)
	if err != nil && !gapiutil.IsErrorWithCode(err, http.StatusNotFound) {
		return false, err
	}

	// Verify that the dataset exists in the requested region.
	if err == nil {
		if c.location != metadata.Location {
			return false, messages.DatasetExistError{Name: c.datasetID, CreateRegion: c.location, ExistRegion: metadata.Location}.Error()
		}
		return false, nil
	}

	// If statusNotFound == true.
	err = dataset.Create(ctx, &bq.DatasetMetadata{
		Name:     c.datasetID,
		Location: c.location,
	})
	if err != nil {
		return false, err
	}
	return true, nil

}