Builtin Types
l always want to know earlier the builtin type of a new language , how is it different from the other languages.
here is an quick overview of the builtin type of Golang :
Types | Description | Values | Remark |
---|---|---|---|
bool | bool is the set of boolean values | true and false | |
uint8 | uint8 is the set of all unsigned 8-bit integers | 0 ~ 255 | |
uint16 | uint16 is the set of all unsigned 16-bit integers | 0 ~ 65535 | |
uint32 | uint32 is the set of all unsigned 32-bit integers | 0 ~ 4294967295 | |
uint64 | int64 is the set of all signed 64-bit integers | 0 ~ 18446744073709551615 | |
int8 | int8 is the set of all signed 8-bit integers | -128 ~ 127 | |
int16 | int16 is the set of all signed 16-bit integers | -32768 ~ 32767 | |
int32 | int32 is the set of all signed 32-bit integers | -2147483648 ~ 2147483647 | |
int64 | int64 is the set of all signed 64-bit integers | -9223372036854775808 ~ 9223372036854775807 | |
float32 | float32 is the set of all IEEE-754 32-bit floating-point numbers | ||
float64 | float64 is the set of all IEEE-754 64-bit floating-point numbers | ||
complex64 | complex64 is the set of all complex numbers with float32 real and imaginary parts | ||
complex128 | complex128 is the set of all complex numbers with float64 real and imaginary parts | ||
string | string is the set of all strings of 8-bit bytes, conventionally but not necessarily representing UTF-8-encoded text. A string may be empty, but not nil. Values of string type are immutable | ||
int | int is a signed integer type that is at least 32 bits in size.It is a distinct type, however, and not an alias for, say, int32 | ||
uint | uint is an unsigned integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, uint32. | ||
uintptr | uintptr is an integer type that is large enough to hold the bit pattern of any pointer. | ||
byte | byte is an alias for uint8 and is equivalent to uint8 in all ways. It is used, by convention, to distinguish byte values from 8-bit unsigned integer values. | ||
rune | rune is an alias for int32 and is equivalent to int32 in all ways. It is used, by convention, to distinguish character values from integer values | ||
Constants | |||
true,false | true and false are the two untyped boolean values | ||
iota | iota is a predeclared identifier representing the untyped integer ordinal number of the current const specification in a (usually parenthesized) const declaration. It is zero-indexed | Untyped int | |
Zero Value | |||
nil | nil is a predeclared identifier representing the zero value for a pointer, channel, func, interface, map, or slice type | ||
Functions | |||
append | append(slice []Type, elems ...Type) []Type | ||
copy | copy(dst, src []Type) int | ||
delete | delete(m map[Type]Type1, key Type) | ||
len | len(v Type) int | ||
cap | cap(v Type) int | ||
make | make(Type, size IntegerType) Type | ||
new | new(Type) *Type | ||
complex | complex(r, i FloatType) ComplexType | ||
real | real(c ComplexType) FloatType | ||
imag | imag(c ComplexType) FloatType | ||
close | close(c chan<- Type) | ||
panic | panic(v interface{}) | ||
recover | recover() interface{} | ||
print(args ...Type) | |||
println | println(args ...Type) | - |