Changelog History
Page 15
-
v0.5.0 Changes
- bigquery:
- The SQL types DATE, TIME and DATETIME are now supported. They correspond to
the
Date
,Time
andDateTime
types in the newcloud.google.com/go/civil
package. - Support for query parameters.
- Support deleting a dataset.
- Values from INTEGER columns will now be returned as int64, not int. This will avoid errors arising from large values on 32-bit systems.
- The SQL types DATE, TIME and DATETIME are now supported. They correspond to
the
- datastore:
- Nested Go structs encoded as Entity values, instead of a
flattened list of the embedded struct's fields. This means that you may now have twice-nested slices, eg.
go type State struct { Cities []struct{ Populations []int } }
See the announcement for more details. - Contexts no longer hold namespaces; instead you must set a key's namespace explicitly. Also, key functions have been changed and renamed.
- The WithNamespace function has been removed. To specify a namespace in a Query, use the Query.Namespace method:
go q := datastore.NewQuery("Kind").Namespace("ns")
- All the fields of Key are exported. That means you can construct any Key with a struct literal:
go k := &Key{Kind: "Kind", ID: 37, Namespace: "ns"}
- As a result of the above, the Key methods Kind, ID, d.Name, Parent, SetParent and Namespace have been removed.
NewIncompleteKey
has been removed, replaced byIncompleteKey
. Replacego NewIncompleteKey(ctx, kind, parent)
withgo IncompleteKey(kind, parent)
and if you do use namespaces, make sure you set the namespace on the returned key.NewKey
has been removed, replaced byNameKey
andIDKey
. Replacego NewKey(ctx, kind, name, 0, parent) NewKey(ctx, kind, "", id, parent)
withgo NameKey(kind, name, parent) IDKey(kind, id, parent)
and if you do use namespaces, make sure you set the namespace on the returned key.- The
Done
variable has been removed. Replacedatastore.Done
withiterator.Done
, from the packagegoogle.golang.org/api/iterator
. - The
Client.Close
method will have a return type of error. It will return the result of closing the underlying gRPC connection. - See the announcement for more details.
- Nested Go structs encoded as Entity values, instead of a
flattened list of the embedded struct's fields. This means that you may now have twice-nested slices, eg.
- bigquery:
-
v0.4.0 Changes
bigquery: -
NewGCSReference
is now a function, not a method onClient
.Table.LoaderFrom
now accepts aReaderSource
, enabling loading data into a table from a file or anyio.Reader
.- Client.Table and Client.OpenTable have been removed.
Replace
go client.OpenTable("project", "dataset", "table")
withgo client.DatasetInProject("project", "dataset").Table("table")
- Client.CreateTable has been removed.
Replace
go client.CreateTable(ctx, "project", "dataset", "table")
withgo client.DatasetInProject("project", "dataset").Table("table").Create(ctx)
- Dataset.ListTables have been replaced with Dataset.Tables.
Replace
go tables, err := ds.ListTables(ctx)
withgo it := ds.Tables(ctx) for { table, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: use table. }
- Client.Read has been replaced with Job.Read, Table.Read and Query.Read.
Replace
go it, err := client.Read(ctx, job)
withgo it, err := job.Read(ctx)
and similarly for reading from tables or queries. - The iterator returned from the Read methods is now named RowIterator. Its
behavior is closer to the other iterators in these libraries. It no longer
supports the Schema method; see the next item.
Replace
go for it.Next(ctx) { var vals ValueList if err := it.Get(&vals); err != nil { // TODO: Handle error. } // TODO: use vals. } if err := it.Err(); err != nil { // TODO: Handle error. }
withfor { var vals ValueList err := it.Next(&vals) if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: use vals. }
Instead of theRecordsPerRequest(n)
option, writego it.PageInfo().MaxSize = n
Instead of theStartIndex(i)
option, writego it.StartIndex = i
- ValueLoader.Load now takes a Schema in addition to a slice of Values.
Replace
go func (vl *myValueLoader) Load(v []bigquery.Value)
withgo func (vl *myValueLoader) Load(v []bigquery.Value, s bigquery.Schema)
- Table.Patch is replace by Table.Update.
Replace
go p := table.Patch() p.Description("new description") metadata, err := p.Apply(ctx)
withgo metadata, err := table.Update(ctx, bigquery.TableMetadataToUpdate{ Description: "new description", })
- Client.Copy is replaced by separate methods for each of its four functions. All options have been replaced by struct fields.
- To load data from Google Cloud Storage into a table, use Table.LoaderFrom.
Replace
client.Copy(ctx, table, gcsRef)
with
table.LoaderFrom(gcsRef).Run(ctx)
Instead of passing options to Copy, set fields on the Loader:
loader := table.LoaderFrom(gcsRef) loader.WriteDisposition = bigquery.WriteTruncate
- To extract data from a table into Google Cloud Storage, use Table.ExtractorTo. Set fields on the returned Extractor instead of passing options.
Replace
client.Copy(ctx, gcsRef, table)
with
table.ExtractorTo(gcsRef).Run(ctx)
- To copy data into a table from one or more other tables, use Table.CopierFrom. Set fields on the returned Copier instead of passing options.
Replace
client.Copy(ctx, dstTable, srcTable)
with
dst.Table.CopierFrom(srcTable).Run(ctx)
- To start a query job, create a Query and call its Run method. Set fields on the query instead of passing options.
Replace
client.Copy(ctx, table, query)
with
query.Run(ctx)
- Table.NewUploader has been renamed to Table.Uploader. Instead of options,
configure an Uploader by setting its fields.
Replace
go u := table.NewUploader(bigquery.UploadIgnoreUnknownValues())
withgo u := table.NewUploader(bigquery.UploadIgnoreUnknownValues()) u.IgnoreUnknownValues = true
๐ฆ pubsub: remove
pubsub.Done
. Useiterator.Done
instead, whereiterator
is the packagegoogle.golang.org/api/iterator
.
-
v0.3.0 Changes
November 11, 2020storage:
- AdminClient replaced by methods on Client.
Replace
go adminClient.CreateBucket(ctx, bucketName, attrs)
withgo client.Bucket(bucketName).Create(ctx, projectID, attrs)
- BucketHandle.List replaced by BucketHandle.Objects.
Replace
go for query != nil { objs, err := bucket.List(d.ctx, query) if err != nil { ... } query = objs.Next for _, obj := range objs.Results { fmt.Println(obj) } }
withgo iter := bucket.Objects(d.ctx, query) for { obj, err := iter.Next() if err == iterator.Done { break } if err != nil { ... } fmt.Println(obj) }
(Theiterator
package is atgoogle.golang.org/api/iterator
.)
Replace
Query.Cursor
withObjectIterator.PageInfo().Token
.Replace
Query.MaxResults
withObjectIterator.PageInfo().MaxSize
.- ObjectHandle.CopyTo replaced by ObjectHandle.CopierFrom.
Replace
go attrs, err := src.CopyTo(ctx, dst, nil)
withgo attrs, err := dst.CopierFrom(src).Run(ctx)
Replace
attrs, err := src.CopyTo(ctx, dst, &storage.ObjectAttrs{ContextType: "text/html"})
with
c := dst.CopierFrom(src) c.ContextType = "text/html" attrs, err := c.Run(ctx)
- ObjectHandle.ComposeFrom replaced by ObjectHandle.ComposerFrom.
Replace
go attrs, err := dst.ComposeFrom(ctx, []*storage.ObjectHandle{src1, src2}, nil)
withgo attrs, err := dst.ComposerFrom(src1, src2).Run(ctx)
- ObjectHandle.Update's ObjectAttrs argument replaced by ObjectAttrsToUpdate.
Replace
go attrs, err := obj.Update(ctx, &storage.ObjectAttrs{ContextType: "text/html"})
withgo attrs, err := obj.Update(ctx, storage.ObjectAttrsToUpdate{ContextType: "text/html"})
- ObjectHandle.WithConditions replaced by ObjectHandle.If.
Replace
go obj.WithConditions(storage.Generation(gen), storage.IfMetaGenerationMatch(mgen))
withgo obj.Generation(gen).If(storage.Conditions{MetagenerationMatch: mgen})
Replace
obj.WithConditions(storage.IfGenerationMatch(0))
with
obj.If(storage.Conditions{DoesNotExist: true})
storage.Done
replaced byiterator.Done
(from packagegoogle.golang.org/api/iterator
).
- AdminClient replaced by methods on Client.
Replace
๐ฆ Package preview/logging deleted. Use logging instead.
-
v0.2.0 Changes
October 29, 2020๐ Logging client replaced with preview version (see below).
๐ New clients for some of Google's Machine Learning APIs: Vision, Speech, and Natural Language.
๐ฒ Preview version of a new [Stackdriver Logging][cloud-logging] client in ๐ฒ
cloud.google.com/go/preview/logging
. ๐ฒ This client uses gRPC as its transport layer, and supports log reading, sinks ๐ฒ and metrics. It will replace the current client atcloud.google.com/go/logging
shortly.