Data Types in Go
In Go (Golang), data types are used to specify the type of values that variables can hold or functions can return. Go is a statically-typed language, which means that you must explicitly declare the data type of a variable when you define it. The data types in Go can be categorized into several basic categories:
- Numeric Types:
int
: Signed integers that can hold positive and negative whole numbers (e.g., -10, 0, 42).uint
: Unsigned integers that can only hold non-negative whole numbers (e.g., 0, 42).float32
,float64
: Floating-point numbers with single and double precision (e.g., 3.14, 2.718).complex64
,complex128
: Complex numbers with single and double precision (e.g., 2+3i, 1.5-2i).
Example:
Read More