Skip to content

StructSaver example invalid #9210

@3052

Description

@3052

here:
https://godocs.io/cloud.google.com/go/bigquery#hdr-Loading_and_Uploading

I see this:

You can also upload a struct that doesn't implement ValueSaver. Use the StructSaver type to specify the schema and insert ID by hand, or just supply the struct or struct pointer directly and the schema will be inferred:

type Item2 struct {
    Name  string
    Size  float64
    Count int
}
// Item implements the ValueSaver interface.
items2 := []*Item2{
    {Name: "n1", Size: 32.6, Count: 7},
    {Name: "n2", Size: 4, Count: 2},
    {Name: "n3", Size: 101.5, Count: 1},
}
if err := u.Put(ctx, items2); err != nil {
    // TODO: Handle error.
}

but the text doesnt match the example. the example does not use StructSaver, the comment in the example refers to Item, which is not actually in the code, and the comment refers to ValueSaver, which the whole point of the code block is to demonstrate NOT using ValueSaver

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions