.. | ||
admin/instance/apiv1 | ||
apiv1 | ||
appengine.go | ||
batch.go | ||
CHANGES.md | ||
client.go | ||
doc.go | ||
errors.go | ||
errors112.go | ||
errors113.go | ||
go.mod | ||
go.sum | ||
go_mod_tidy_hack.go | ||
key.go | ||
LICENSE | ||
mutation.go | ||
not_appengine.go | ||
pdml.go | ||
protoutils.go | ||
read.go | ||
README.md | ||
retry.go | ||
row.go | ||
session.go | ||
sessionclient.go | ||
statement.go | ||
stats.go | ||
timestampbound.go | ||
transaction.go | ||
value.go |
Cloud Spanner
Example Usage
First create a spanner.Client
to use throughout your application:
client, err := spanner.NewClient(ctx, "projects/P/instances/I/databases/D")
if err != nil {
log.Fatal(err)
}
// Simple Reads And Writes
_, err = client.Apply(ctx, []*spanner.Mutation{
spanner.Insert("Users",
[]string{"name", "email"},
[]interface{}{"alice", "a@example.com"})})
if err != nil {
log.Fatal(err)
}
row, err := client.Single().ReadRow(ctx, "Users",
spanner.Key{"alice"}, []string{"email"})
if err != nil {
log.Fatal(err)
}