_content/doc: ensure database example code compiles
The CreateOrder example function fails to compile for two reasons:
A helper function with wrong number of return values (want 2, got 1).
A short variable declaration (:=) does not declare new variables.
This change resolves the compiler error, allowing the code to compile.
Fixes golang/go#50508
Change-Id: Ife07ae1490969ae67525b9171ab4fcd424409c1c
Reviewed-on: https://go-review.googlesource.com/c/website/+/376974
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/_content/doc/database/execute-transactions.md b/_content/doc/database/execute-transactions.md
index e1bd353..5060cda 100644
--- a/_content/doc/database/execute-transactions.md
+++ b/_content/doc/database/execute-transactions.md
@@ -114,7 +114,7 @@
// Create a helper function for preparing failure results.
fail := func(err error) (int64, error) {
- return fmt.Errorf("CreateOrder: %v", err)
+ return 0, fmt.Errorf("CreateOrder: %v", err)
}
// Get a Tx for making transaction requests.
@@ -152,7 +152,7 @@
return fail(err)
}
// Get the ID of the order item just created.
- orderID, err := result.LastInsertId()
+ orderID, err = result.LastInsertId()
if err != nil {
return fail(err)
}