Skip to content

Commit

Permalink
_content/doc: ensure database example code compiles
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Emmanuel Odeke <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
willpoint authored and gopherbot committed Mar 24, 2023
1 parent a1d570e commit 43688dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _content/doc/database/execute-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func CreateOrder(ctx context.Context, albumID, quantity, custID int) (orderID in
// 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.
Expand Down Expand Up @@ -152,7 +152,7 @@ func CreateOrder(ctx context.Context, albumID, quantity, custID int) (orderID in
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)
}
Expand Down

0 comments on commit 43688dc

Please sign in to comment.