Kiểu dữ liệu trong Go
Trong ngôn ngữ lập trình Go, các kiểu dữ liệu tham chiếu đến một hệ thống mở rộng được sử dụng để khai báo các biến hoặc các hàm của các kiểu dữ liệu khác nhau. Kiểu của một biến xác định bởi không gian bộ nhớ để lưu trữ.
Các kiểu dữ liệu trong Go có thể được phân loại như sau:
# | Kiểu dữ liệu |
1 |
Boolean Bao gồm 2 giá trị: (a) true - (b) false |
2 |
Numeric Bao gồm các kiểu số: (a) integer - (b) float |
3 |
String Kiểu dữ liệu String là một tập (set) các giá trị string. Giá trị của nó là một chuỗi các byte. String là kiểu bất biến được tạo ra một lần, không thể thay đổi nội dung của chuỗi. Loại chuỗi được khai báo trước là chuỗi. |
4 |
Derived Bao gồm:
|
Integer types
# | Types and Description |
---|---|
1 |
uint8 Unsigned 8-bit integers (0 to 255) |
2 |
uint16 Unsigned 16-bit integers (0 to 65535) |
3 |
uint32 Unsigned 32-bit integers (0 to 4294967295) |
4 |
uint64 Unsigned 64-bit integers (0 to 18446744073709551615) |
5 |
int8 Signed 8-bit integers (-128 to 127) |
6 |
int16 Signed 16-bit integers (-32768 to 32767) |
7 |
int32 Signed 32-bit integers (-2147483648 to 2147483647) |
8 |
int64 Signed 64-bit integers (-9223372036854775808 to 9223372036854775807) |
Float types
# | Types and Description |
---|---|
1 |
float32 IEEE-754 32-bit floating-point numbers |
2 |
float64 IEEE-754 64-bit floating-point numbers |
3 |
complex64 Complex numbers with float32 real and imaginary parts |
4 |
complex128 Complex numbers with float64 real and imaginary parts |
Other Numberic types:
# | Types and Description |
---|---|
1 |
byte same as uint8 |
2 |
rune same as int32 |
3 |
uint 32 or 64 bits |
4 |
int same size as uint |
5 |
uintptr an unsigned integer to store the uninterpreted bits of a pointer value |
No Comments