Try   HackMD

Basic Syntax (基礎語法)

tags: Go

if else

https://gobyexample.com/if-else

Example

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

for i := 0; i < 10; i++ {
    sum += i
}

foeach

https://syntaxdb.com/ref/go/for-each

Example

studentGrades := [3]int{50, 89, 75}

for _, grade := range studentGrades { 
    fmt.Println("Grade: ", grade)
}

Output

N/A