data types Flashcards

(8 cards)

1
Q

bool

A

Values: true or false
Zero Value: false
Example:

go
var isReady bool = true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Signed Integers

A

int: Platform-dependent (32/64-bit)

int8: 8-bit (-128 to 127)

int16: 16-bit (-32,768 to 32,767)

int32: 32-bit (-2.1B to 2.1B)

int64: 64-bit
Zero Value: 0
Example:

go
var age int = 30

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

byte

A

Alias for: uint8 (0 to 255)
Use Case: Raw binary data (e.g., file/network streams).
Example:

go
var b byte = ‘A’ // ASCII 65

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Unsigned Integers

A

uint: Platform-dependent (32/64-bit)

**uint8/byte: 0 to 255

uint16: 0 to 65,535

uint32: 0 to 4.2B

uint64: 0 to 18 quintillion
Zero Value: 0
Example:

go
var count uint32 = 100000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

rune

A

Alias for: int32
Use Case: Unicode code points (e.g., ‘☺’, ‘あ’).
Example:

go
var emoji rune = ‘🔥’ // Unicode U+1F525

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Floating-Point

A

float32: 6-7 decimal digits precision

float64: 15-16 digits (preferred)
Zero Value: 0.0
Example:

go
var pi float64 = 3.1415926535

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Complex Numbers

A

complex64: float32 real/imaginary parts

complex128: float64 real/imaginary parts
Zero Value: (0+0i)
Example:

go
var z complex128 = 3 + 4i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

uintptr

A

Purpose: Holds memory addresses (unsafe, low-level programming).
Example:

go
var ptr uintptr = uintptr(unsafe.Pointer(&x))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly