如何在bigquery中创建DateTime字段并在golang中对其进行更新?

here is basically my creation script for bigquery in golang :

type data_pix struct {
    Id string
    IdC string
    Stamp   int64
    Tag []string


}
func createTable(client *bigquery.Client, datasetID, tableID string) error {
    ctx := context.Background()
    // [START bigquery_create_table]
    schema, err := bigquery.InferSchema(data_pix{})
    if err != nil {
        return err
    }
    table := client.Dataset(datasetID).Table(tableID)
    if err := table.Create(ctx, schema); err != nil {
        return err
    }
    // [END bigquery_create_table]
    return nil
}

for the moment i use mainly a timestamp in Int64.

But i am looking for any example on how to add Datetime to my struct and btw add Datetime to my data

Thanks and regards

I have not used the bigquery, however I had a look at the godoc and source code.

It seems, you have to use data type civil.DateTime reference in the struct.

For e.g:

As per godoc and source code, following should create DateTime field.

type data_pix struct {
   Id      string
   IdC     string
   Stamp   civil.DateTime
   Tag     []string
}

schema, err := bigquery.InferSchema(data_pix{})
// now schema should represent DateTime Field

There is a function to get civil.DateTime from time.Time. I would suggest you have a look at this go sourcecode to know more.