tree: b9d5f7d2e0322267f21ca9076c4b4dc9e44ba53b [path history] [tgz]
  1. admin/
  2. aliasshim/
  3. apiv1/
  4. internal/
  5. kokoro/
  6. spannertest/
  7. spansql/
  8. batch.go
  9. batch_test.go
  10. big_pdml_test.go
  11. CHANGES.md
  12. client.go
  13. client_benchmarks_test.go
  14. client_test.go
  15. cmp_test.go
  16. doc.go
  17. emulator_test.sh
  18. errors.go
  19. errors112.go
  20. errors113.go
  21. errors_test.go
  22. examples_test.go
  23. go.mod
  24. go.sum
  25. integration_test.go
  26. key.go
  27. key_test.go
  28. mutation.go
  29. mutation_test.go
  30. oc_test.go
  31. pdml.go
  32. pdml_test.go
  33. protoutils.go
  34. read.go
  35. read_test.go
  36. README.md
  37. retry.go
  38. retry_test.go
  39. row.go
  40. row_test.go
  41. session.go
  42. session_test.go
  43. sessionclient.go
  44. sessionclient_test.go
  45. statement.go
  46. statement_test.go
  47. stats.go
  48. timestampbound.go
  49. timestampbound_test.go
  50. transaction.go
  51. transaction_test.go
  52. value.go
  53. value_benchmarks_test.go
  54. value_test.go
spanner/README.md

Cloud Spanner Go Reference

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)
}