go教程
-
Gobreak语句-Go实例教程|
Go break 语句 package main import fmt func main () { /* local variable definition */ var a int = 10 /* for loop execution */ for a 20 { fmt . Printf ( value of a: %d , a ); a ++ ;...
-
Go嵌套for循环-Go实例教程|
Go 嵌套 for 循环 package main import fmt func main () { /* local variable definition */ var i , j int for i = 2 ; i 100 ; i ++ { for j = 2 ; j = ( i / j ); j ++ { if ( i % j == ...
-
Gofor循环-Go实例教程|
Go for 循环 package main import fmt func main () { var b int = 15 var a int numbers := [ 6 ] int { 1 , 2 , 3 , 5 } /* for loop execution */ for a := 0 ; a 10 ; a ++ { fmt . Printf...
-
GoSelect语句-Go实例教程|
Go Select 语句 package main import fmt func main () { var c1 , c2 , c3 chan int var i1 , i2 int select { case i1 = - c1 : fmt . Printf ( received , i1 , from c1 ) case c2 - i2 : f...
-
GoSwitch语句-Go实例教程|
Go Switch语句 package main import fmt func main () { /* local variable definition */ var grade string = B var marks int = 90 switch marks { case 90 : grade = A case 80 : grade = B...
-
Go嵌套if语句-Go实例教程|
Go 嵌套 if 语句 package main import fmt func main () { /* local variable definition */ var a int = 100 var b int = 200 /* check the boolean condition */ if ( a == 100 ) { /* if ...
-
Goifelse语句-Go实例教程|
Go if else 语句 package main import fmt func main () { /* local variable definition */ var a int = 100 ; /* check the boolean condition */ if ( a 20 ) { /* if condition is true th...
-
Goif语句-Go实例教程|
Go if 语句 package main import fmt func main () { /* local variable definition */ var a int = 10 /* check the boolean condition using if statement */ if ( a 20 ) { /* if condition...
-
Go操作符优先级-Go实例教程|
Go操作符优先级 package main import fmt func main () { var a int = 20 var b int = 10 var c int = 15 var d int = 5 var e int ; e = ( a + b ) * c / d ; // ( 30 * 15 ) / 5 fmt . P...
-
Go其他运算符-Go实例教程|
Go 其他运算符 package main import fmt func main () { var a int = 4 var b int32 var c float32 var ptr * int /* example of type operator */ fmt . Printf ( Line 1 - Type of variab...
-
Go赋值运算符-Go实例教程|
Go 赋值运算符 package main import fmt func main () { var a int = 21 var c int c = a fmt . Printf ( Line 1 - = Operator Example, Value of c = %d , c ) c += a fmt . Printf ( Line...
-
Go位运算符-Go实例教程|
Go 位运算符 package main import fmt func main () { var a uint = 60 /* 60 = 0011 1100 */ var b uint = 13 /* 13 = 0000 1101 */ var c uint = 0 c = a b /* 12 = 0000 1100 */ fmt . Pr...
-
Go逻辑运算符-Go实例教程|
Go 逻辑运算符 package main import fmt func main () { var a bool = true var b bool = false if ( a b ) { fmt . Printf ( Line 1 - Condition is true ) } if ( a || b ) { fmt . Print...
-
Go关系运算符-Go实例教程|
Go 关系运算符 package main import fmt func main () { var a int = 21 var b int = 10 if ( a == b ) { fmt . Printf ( Line 1 - a is equal to b ) } else { fmt . Printf ( Line 1 - a ...
-
Go算术运算符-Go实例教程|
Go 算术运算符 package main import fmt func main () { var a int = 21 var b int = 10 var c int c = a + b fmt . Printf ( Line 1 - Value of c is %d , c ) c = a - b fmt . Printf ( L...
-
Goconst关键字-Go实例教程|
Go const 关键字 package main import fmt func main () { const LENGTH int = 10 const WIDTH int = 5 var area int area = LENGTH * WIDTH fmt . Printf ( value of area : %d , area ) }...
-
Go转义字符-Go实例教程|
Go 转义字符 package main import fmt func main () { fmt . Printf ( HelloWorld! ) }...
-
GoMixed变量声明-Go实例教程|
Go Mixed 变量声明 package main import fmt func main () { var a , b , c = 3 , 4 , foo fmt . Println ( a ) fmt . Println ( b ) fmt . Println ( c ) fmt . Printf ( a is of type %T ,...
-
Go动态类型声明-Go实例教程|
Go 动态类型声明 package main import fmt func main () { var x float64 = 20.0 y := 42 fmt . Println ( x ) fmt . Println ( y ) fmt . Printf ( x is of type %T , x ) fmt . Printf (...
-
Go静态类型声明-Go实例教程|
Go 静态类型声明 package main import fmt func main () { var x float64 x = 20.0 fmt . Println ( x ) fmt . Printf ( x is of type %T , x ) }...