Skip to content

Files

Latest commit

f8e3ab7 · Apr 8, 2025

History

History

datastore

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 3, 2025
Dec 2, 2022
Mar 3, 2025
Oct 29, 2024
Aug 22, 2023
Oct 29, 2024
Nov 9, 2021
Aug 22, 2024
Jan 16, 2025
Aug 12, 2019
Aug 22, 2024
Nov 13, 2023
Jun 14, 2018
Nov 13, 2023
Apr 8, 2025
Apr 8, 2025
Jan 16, 2025
Sep 5, 2024
Jun 14, 2018
Apr 15, 2024
Jun 6, 2019
Aug 22, 2024
Aug 22, 2024
Aug 22, 2024
Sep 5, 2024
Aug 22, 2024
Jul 30, 2024
Sep 18, 2023
Aug 22, 2024
Jan 16, 2025
Jan 16, 2025
Aug 22, 2024
Aug 22, 2024
Jun 14, 2018
Jun 14, 2018
Jan 16, 2025
Aug 22, 2024
Aug 22, 2024

Cloud Datastore Go Reference

Example Usage

First create a datastore.Client to use throughout your application:

client, err := datastore.NewClient(ctx, "my-project-id")
if err != nil {
	log.Fatal(err)
}

Then use that client to interact with the API:

type Post struct {
	Title       string
	Body        string `datastore:",noindex"`
	PublishedAt time.Time
}
keys := []*datastore.Key{
	datastore.NameKey("Post", "post1", nil),
	datastore.NameKey("Post", "post2", nil),
}
posts := []*Post{
	{Title: "Post 1", Body: "...", PublishedAt: time.Now()},
	{Title: "Post 2", Body: "...", PublishedAt: time.Now()},
}
if _, err := client.PutMulti(ctx, keys, posts); err != nil {
	log.Fatal(err)
}