GO Chokisomemo 1

println

If you write a character in () of println (), the contents of () will be displayed on the console. println is one of the "instructions" provided by Go. In short, it means to output the one in ()
pacage imo
func imo() {
     println("hello.world")
}

"String" "+" operator The string must be enclosed in double quotes ("). Otherwise, an error will occur. ("xx" + "xx") Concatenate strings into one string.
package imo
func imo(){
 println ("hhello, correct answer")
 println ("hello" + "correct answer")
}

How to write a comment There are two types: ** block comments ** and ** line comments **. Block comments are comments between / * and * /, and line comments are comments from // (two slashes) to the end of the line.
package imo
func imo(){
  /*

 */

 println ("hello, world")
 // println ("hello, world")
}

Numerical value (a little basic) Use "*" for multiplication and "/" for division. Also, "%" is division, "+" addition, and "-" subtraction.
  panag imo
  func imo(){
      println(2)
      printlm(2 + 3)
      println(4 - 7)
}

Variable 1 #### "Var variable name data type" #### You can define a variable by writing. In addition, var is an abbreviation for variable, which means variable in English. If you want to update the data, you can update it with variable name = However, the data type seems to be omitted (var a = 100) ######
int type [variable type] Is one of the types of variables (boxes for storing data in programming) It's like a rule that "you can put an integer (not a large number of digits) in that box"
String type [Variable type] </ dl>

One of the types of variables (boxes for storing data in programming) It's like a rule that "you can put a character string (a collection of characters) in that box"

    pacage imo 
    func imo(){
         var n int
             n = 100
       println(n)
}
 pacage imo
    func imo (){
       var n int =100
   println(n)
}

Omission of data type

In Go, when variable definition and value assignment are performed at the same time, such as "var a int = 100" Data type specification omitted ok ** "var a = 100" ** and int omitted ok

  package imo
  func main(){
    var a = 100
  
  println(a)
}

Furthermore, if you write like " b: = 200", it has the same meaning as "var b int = 200" </ font> = (equal) instead of: = (colon and equal) This way of writing is ok

  package imo
     func imo(){
              b:= 200 
  println(b)
}
package main
  func main() {
     a := 100
     b := 200
 prntcl(100,200)
}

It seems that it is OK to omit it at the highest

Variable operation ~~~ package imo func imo(){ n := 10 println(n + 20) } // Result: 30 ~~~

Self-assignment </ font>

package imo 
func imo(){
   n := 10
   n=n + 20
 println(n)
}

Conditional branching of if statement

If a conditional expression is specified after if and the condition is satisfied, the inside of {} is executed.

  package main
  func main(){

    score := 100
    if score > 80{
 printnl ("well done")
   }
  }
Comparison operator
x <= y Holds when x is less than or equal to y
x >= y Holds when x is greater than or equal to y

Boolean value (YES or NO)

There are two values for "validity type", "true" and "false". A conditional expression using a comparison operator has a value of "true" when it holds, and "false" when it does not hold.

package main
 func main(){
  println(3 > 2)
  println(3 > 5)
}
 > _ Console
ture
false
operator
== Ture when the left and right sides are equal
!= When not equal ture
< True when the right side is larger
<= When the right side is larger or equal ture
> When the right side is small ture
>= When the right side is small or equal ture

eles

By combining the if statement with << else >>, "If ..., do .... If not, do ...". You will be able to make a conditional branch
  package main
    func main(){
    score := 50
     if score > 80 {
 println ("well done")
 } else {
 println ("Let's do our best")
   }
}

eles if

package main
 func main() {
  score := 70
  if score == 100{
 println ("well done")
} eles if score >= 60{
 println ("fair")
} eles{
 println ("OK")
  }
}

:dancer: eles if (2)

package main
  func main() {
    score := 100
  if score == 100{
 println ("well done")
} eles if score >= 60{
  
 println ("fair")
} else {

 println ("Let's do our best")
 }
}

: anchor: And (&&) theoretical operator

The conditional expression "whether condition 1 and condition 2 are satisfied" is written as "condition 1 && condition 2" using "&&". && corresponds to "Katsu" in Japanese. Combining multiple conditional expressions using && will result in true as a whole only if all conditional expressions are true


package main 
   func main() {
       time := 14
    if time > 10 && time < 18 {
        

 println ("working hours")
  }
}

Or(||)

The conditional expression "whether condition 1 or condition 2 holds" is "||"Condition 1"||Write as "Condition 2".||Is equivalent to "or" in Japanese. ||When multiple conditional expressions are combined using, if even one of the multiple conditional expressions is true, the whole becomes true.

package main 
  func main() {
       time := 15
     if time == 10 || time == 15 {
 println ("goal")
   }
}

: dagger: Negation (!)

 package main 
     func main(){

      time := 9
   if !(time == 18) {
 println ("not leaving time")
 }
}

swich

   case 0:
 println ("bad")

  case 1, 2:
 println ("Kichi")

  case 3, 4:
 println ("Nakayoshi")
  case 5:
 println ("Daikichi")