// Create a new key with integer ID 123 key := datastore.NewKey(ctx, "MyEntity", "", 123, nil) // Create a new entity with the key entity := MyEntity{ID: 123, Name: "John"} _, err := datastore.Put(ctx, key, &entity) if err != nil { // Handle error }
// Create a key with integer ID 123 key := datastore.NewKey(ctx, "MyEntity", "", 123, nil) // Retrieve the entity with the key var entity MyEntity err := datastore.Get(ctx, key, &entity) if err != nil { // Handle error }The package library used in these examples is "google.golang.org/appengine/datastore".