Middle+
Millised andmetüübid on Go-s?
sobes.tech AI
Vastus AI-lt
In Go, there are several main data types:
- Boolean:
bool— accepts valuestrueorfalse. - Integer numbers:
int,int8,int16,int32,int64and their unsigned counterpartsuint,uint8(alias forbyte),uint16,uint32,uint64. - Floating-point numbers:
float32,float64. - Complex numbers:
complex64,complex128. - Strings:
string— immutable sequence of bytes. - User-defined types: structures (
struct), interfaces (interface), arrays, slices (slice), maps (map), channels (chan).
Example of declaring variables of different types:
var a int = 10
var b float64 = 3.14
var c bool = true
var s string = "hello"