This is a creation in Article, where the information may have evolved or changed.
Package Mainimport ("FMT") Func main () {varAinta=1 varA1stringA1="my is A1"B:=2B1:="My is B1"FMT. Println (A,"^^^^", A1) Fmt. Println (b,"^^^^", B1)}
[' Go run Test.go ' | done:208.870174ms]
1 ^^ ^^ my is A1
2 ^^ ^^ My is B1
The next piece is interesting, with a python list of shadows, but the go language is called a "byte array"
Package Mainimport ( "fmt") Func main () { A:'my is b" B:= []byte(a) FMT. Println (string(b[0))}
[' Go run Test.go ' | done:190.573207ms]
M
Package Mainimport ( "fmt") Func main () { A:'my is b" + " test" B:= ' My name is ' fmt. Println (a) FMT. Println (b)}
[' Go run Test.go ' | done:197.232301ms]
My is B test
My
Name
Is
var is the one that declares global variables and assigns values.
The definition of a const constant,
Type declaration of a generic type
Package Mainimport ( "fmt") Func main () { var ( " Wang " Age)fmt. Print ("hello""Age was:", Age)}
[' Go run Hello.go ' | done:201.697722ms]
Hellowangage Is:12
Type lingzhii:
When a variable is declared as a default value after some type,
Typically, the value type is 0
BOOL is False
String is empty
Package Mainimport ( "fmt") Func main () { varint varstring varbool FMT. Println (a) FMT. Println (b) FMT. Println (c)}
[' Go run Test1.go ' | done:215.061592ms]
0
False