Go process control

Process Control

Go language support program is running three basic structures: sequential structure, select the structure, loop structure.

  •  Sequential structure: program executed in order to jump does not occur.
  •  Select structure: depending on whether the condition is satisfied, perform the corresponding function have a choice.
  •  Loop structure: according to whether the conditions are met, the cycle repeatedly execute a piece of code.

1 Select structure

1.1 if statement

1.1.1 if
main Package 

Import " fmt " 

FUNC main () { 
    S: = " grass root " 
    // if {and that conditions, conditions generally are relational operators 
    if S == " Sicong " {   // left parenthesis in the same row and if 
        fmt .Println ( " left a sister paper, a right Mother " ) 
    } 

    // IF statement initializes a support, and determination condition initialization statement separated by semicolons 
    IF a: = 10 ; a == 10 {   // condition is true, {statement} directed 
        fmt.Println ( " A == 10 " ) 

    } 
}

 

Guess you like

Origin www.cnblogs.com/huiyichanmian/p/11361138.html