Middle+
What data types are available in Go?
sobes.tech AI
Answer from AI
In Go, there are several basic data types:
- Boolean:
bool— accepts valuestrueorfalse. - Integer:
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— an 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"