go: Update "statements in if" use case (#1199)

Co-authored-by: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
This commit is contained in:
headdetect 2020-08-03 06:19:23 -06:00 committed by GitHub
parent 9e0dbeddce
commit aef8d25a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

4
go.md
View File

@ -184,13 +184,13 @@ See: [If](https://tour.golang.org/flowcontrol/5)
### Statements in if ### Statements in if
```go ```go
if _, err := getResult(); err != nil { if _, err := doThing(); err != nil {
fmt.Println("Uh oh") fmt.Println("Uh oh")
} }
``` ```
{: data-line="1"} {: data-line="1"}
A condition in an `if` statement can be preceded with a statement before a `;`. A condition in an `if` statement can be preceded with a statement before a `;`. Variables declared by the statement are only in scope until the end of the `if`.
See: [If with a short statement](https://tour.golang.org/flowcontrol/6) See: [If with a short statement](https://tour.golang.org/flowcontrol/6)