This is the first day of my participation in the August Text Challenge.More challenges in August
The Go
Go is a statically typed language
It is also a procedural language, so don’t learn Go with an object-oriented mind
The code writing is very simple. In my eyes, it has the simplicity and easy to use of C language, and the running speed is comparable to THAT of C
It also has the power of the Java language, built in many system standard libraries, rather than relying on other third-party libraries and frameworks
If you master Go, then you master the future!!
The Boolean
Bool. The value can only be true or false
The constant definition of true and false in Go
const ( true = 0 == 0 // Untyped bool. false = 0 ! = 0 // Untyped bool. )Copy the code
The integer
Int – signed, depending on the operating system on which the runtime is running
Int8 – The value ranges from -27 to 27-1
Int16 – The value ranges from -215 to 215-1
Int32 – The value ranges from -231 to 231-1
Int64 – The value ranges from -263 to 263-1
Uint – Unsigned, depending on the operating system on which the runtime is running
Uint8 – Can represent range: 0 ~ 28-1
Uint16 – Can represent range: 0 ~ 216-1
Uint32 – The value ranges from 0 to 232-1
Uint64 – Expressed in sectors ranging from 0 to 264-1
Var UI uint = -10; var UI uint = -10; var UI uint = -10; //fmt.Println(ui)Copy the code
floating-point
Float32, provides accuracy to 6 decimal places
Float64, provides accuracy to 15 decimal places
Var f float32 = 3.14ftt. Println(f) // Float32, Println(f2) // Float64 Indicates the number of floating points. Var f3 Float64 = 1.123456789 fmt.Println(f3)Copy the code
The plural
complex64
Both the real and imaginary parts are of type FLOAT32
complex128
Both the real and imaginary parts are of type FLOAT64
Println(c1) var c1 complex64 = complex64 (5, complex64) var c1 complex64 = complex64 (5, complex64) var c1 complex64 = complex64 Var im float32 = imag(c2) var im float32 = imag(c2) fmt.Println(im)Copy the code
String type
Strings in the Go language use utF-8 encoding to represent Unicode characters
When we define a string, if there’s no assignment, it’s a string of length zero and the value of the string is immutable
var s string = "hi, go!" FMT.Println(s) // An empty string of 0 characters var snil string; fmt.Println(len(snil))Copy the code
uintptr
An unsigned integer value that can represent any address and be evaluated numerically
byte
Equivalent to uint8, used to represent the ASCII code table
rune
Equivalent to INT32, used when dealing with Unicode characters
nil
Zero values that can represent Pointers, channels, functions, interfaces, maps, slices
So nil must be assigned to a pointer type variable
The derived type
Pointer type Array type Structure type Channel Type Function Type Slice type Interface type Mapping type
The representation of different base numbers
Println(0b100) // Octal: 0 is the prefix, e.g. 012 is the prefix of 10 fmt.Println(012) // Hexadecimal: 0x is the prefix, e.g. : 0x23:35 FMT.Println(0x23)Copy the code