Senior
What data types do you know in Go?
sobes.tech AI
Answer from AI
In Go, there are several basic data types:
- Boolean:
bool(true/false) - Integer types:
int,int8,int16,int32,int64, as well as unsigneduint,uint8(alias byte),uint16,uint32,uint64 - Floating-point numbers:
float32,float64 - Complex numbers:
complex64,complex128 - Strings:
string - Byte slices:
[]byte
Besides the basic types, there are composite types:
- Arrays and slices
- Structs (
struct) - Maps (
map) - Interfaces (
interface{}) - Channels (
chan)
Example of declaring variables:
var a int = 10
var b float64 = 3.14
var c bool = true
var s string = "hello"
var arr []int = []int{1, 2, 3}