Title string
1. Define variable
var + + Variable Type Variable Name
Variable name: = value (automatically determined by the type of system)
does not have a default value after the traditional values define the variable type, such as int default value is 0.
2.int64 turn String
Go is a strongly typed language, you must type in order to unify operations
package main
import "fmt"
func testVar(){
var i int64
var s string
fmt.Println("i is", i)
fmt.Println("s is", s)
ii := 88
ss := "hello go"
fmt.Println("ii is", ii)
fmt.Println("ss is", ss)
}
func testBool(){
var b1 bool
b2 := true
b3 := false
fmt.Println(b1, b2, b3)
}
func testNumber(){
var i int64
var i2 int64
fmt.Println(i, i2)
i3 := 10
i4 := int64(10)
fmt.Println(int64(i3),i4)
}
func main(){
testVar()
testBool()
testNumber()
}
result:
i is 0
s is
ii is 88
ss is hello go
false true false
0 0
10 10