-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gae): delete old region tags #5102
fix(gae): delete old region tags #5102
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team,
I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:
This pull request, submitted by OremGLG, aims to delete old region tags in the golang-samples
repository. The changes are driven by the need to address several issues (b/391176362, b/389106593, b/391176883, b/391175192, b/391176374, b/391176575, b/391175195, b/391176890).
Here's a breakdown of the changes:
- The file
docs/appengine/datastore/entities/entities.go
has been modified. Specifically, lines 34-35, 44, 51, 60, 71, 83, 92, 99, 116, and 125 have been altered. These changes appear to remove several instances of outdated region tags (// [START ... ]
and// [END ... ]
) from code comments.
The author has indicated that the code is formatted (gofmt
) and vetted (go vet
), and the contributing guidelines have been followed. However, tests are not yet complete.
I'll provide a more detailed review shortly.
And now, a little haiku to brighten your day:
Tags cleaned, code refined,
Clarity shines, a brighter view,
Review now complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request removes redundant region tags from the entities.go
file. Removing these tags improves the clarity and maintainability of the code, as it avoids potential confusion caused by duplicate tags. The changes are well-targeted and effectively address the identified issues related to redundant region tags. I recommend adding tests to verify the correctness of the code after these changes, as described in the Contributing Guidelines. I've also noticed that the checklist in the pull request description is not fully completed. Please ensure that all items in the checklist are addressed before merging.
@@ -31,7 +31,6 @@ type Address struct{} | |||
|
|||
func example() { | |||
// [START gae_datastore_batch] | |||
// [START batch] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// A batch delete. | ||
err = datastore.DeleteMulti(ctx, []*datastore.Key{k1, k2, k3}) | ||
// [END batch] | ||
// [END gae_datastore_batch] | ||
_ = err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The redundant batch
tag has been correctly removed. Consider adding a comment explaining the purpose of the datastore.DeleteMulti
function and its usage in the context of batch operations. For example, you could add a comment like this:
// Delete multiple entities in a batch operation.
// This is more efficient than deleting them individually.
// A batch delete. | |
err = datastore.DeleteMulti(ctx, []*datastore.Key{k1, k2, k3}) | |
// [END batch] | |
// [END gae_datastore_batch] | |
_ = err | |
// A batch delete. | |
err = datastore.DeleteMulti(ctx, []*datastore.Key{k1, k2, k3}) | |
// [END gae_datastore_batch] | |
_ = err |
key := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil) | ||
err = datastore.Delete(ctx, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the delete
region tag is appropriate. To improve code readability, consider adding a comment that explains the purpose of this code block, such as:
// Delete a single entity from the datastore.
key := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil) | |
err = datastore.Delete(ctx, key) | |
key := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil) | |
err = datastore.Delete(ctx, key) |
employeeKey := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil) | ||
addressKey := datastore.NewKey(ctx, "Address", "", 1, employeeKey) | ||
var addr Address | ||
err = datastore.Get(ctx, addressKey, &addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the get_key
tag is correct. To enhance code clarity, consider adding a comment explaining the purpose of retrieving the address using datastore.Get
, such as:
// Retrieve an Address entity from the datastore using its key.
employeeKey := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil) | |
addressKey := datastore.NewKey(ctx, "Address", "", 1, employeeKey) | |
var addr Address | |
err = datastore.Get(ctx, addressKey, &addr) | |
employeeKey := datastore.NewKey(ctx, "Employee", "asalieri", 0, nil) | |
addressKey := datastore.NewKey(ctx, "Address", "", 1, employeeKey) | |
var addr Address | |
err = datastore.Get(ctx, addressKey, &addr) |
// Create a key such as Employee:8261. | ||
key := datastore.NewKey(ctx, "Employee", "", 0, nil) | ||
// This is equivalent: | ||
key = datastore.NewIncompleteKey(ctx, "Employee", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key_id
tag was removed correctly. Consider adding a comment explaining the purpose of creating keys with and without IDs, for example:
// Demonstrates creating keys with and without explicit IDs.
// An incomplete key generates an ID automatically.
// Create a key such as Employee:8261. | |
key := datastore.NewKey(ctx, "Employee", "", 0, nil) | |
// This is equivalent: | |
key = datastore.NewIncompleteKey(ctx, "Employee", nil) | |
// Create a key such as Employee:8261. | |
key := datastore.NewKey(ctx, "Employee", "", 0, nil) | |
// This is equivalent: | |
key = datastore.NewIncompleteKey(ctx, "Employee", nil) |
Here is the summary of changes. You are about to delete 8 region tags.
This comment is generated by snippet-bot.
|
Description
Delete old region tags
Fixes
b/391176362
b/389106593
b/391176883
b/391175192
b/391176374
b/391176575
b/391175195
b/391176890
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
go test -v ./..
(see Testing)gofmt
(see Formatting)go vet
(see Formatting)