# Basic Syntax (基礎語法) ###### tags: `Go` ## if ... else ... > https://gobyexample.com/if-else Example ```go if 7%2 == 0 { fmt.Println("7 is even") } else { fmt.Println("7 is odd") } ``` Output ``` 7 is odd ``` ## for loop > https://tour.golang.org/flowcontrol/1 Example ```go for i := 0; i < 10; i++ { sum += i } ``` ## foeach > https://syntaxdb.com/ref/go/for-each Example ```go studentGrades := [3]int{50, 89, 75} for _, grade := range studentGrades { fmt.Println("Grade: ", grade) } ``` Output ``` N/A ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up