从Cloud Storage获取JSON文件的BigQuery加载表的代码; 自动检测模式

I would like to load a table in BigQuery from json-formatted Google Cloud Storage files, and have the 'auto-detect schema' option as available in the BigQuery Console UI enabled.

I would like to do this in Go using the BigQuery package cloud.google.com/go/bigquerybut cannot figure it out from the docs. Can someone provide a code sample? I don't want to use Python.

Thanks for the reference. The FileConfig struct has to be set as an attribute of GCSReference:

// Load JSON formatted files from
// Google Cloud Storage to BigQuery
// Auto-detect schema
func LoadTblJson(ctx context.Context, client *bigquery.Client,
    pth string, datasetName string, tableName string) {


    dataset := client.Dataset(datasetName)
    gcsRef := bigquery.NewGCSReference(pth)

    // set FileConfig attribute of GCSReference struct
    var dataFormat bigquery.DataFormat
    dataFormat = "NEWLINE_DELIMITED_JSON"
    flConfig := bigquery.FileConfig{SourceFormat: dataFormat,
        AutoDetect: true, Schema: nil}
    gcsRef.FileConfig = flConfig


    loader := dataset.Table(tableName).LoaderFrom(gcsRef)
    loader.CreateDisposition = bigquery.CreateIfNeeded
    loader.WriteDisposition = bigquery.WriteEmpty

    job, err := loader.Run(ctx)
    if err != nil {
        //Handle
    }
    status, err := job.Wait(ctx)
    if err != nil {
        // Handle
    }
    if status.Err() != nil {
        //Handle
    }



}

</div>