Basics: Types, Variables and Constants

In today’s post we will learn basics of Go language like supported Types, how to declare and initialize variables and constants. Just like any other language, Go has its own way of declaring and initializing variables and constants. Data Types Boolean: Used for true and false. Use bool to declare variable of type Boolean. Numeric: Go supports unsigned, signed integer, float, complex, byte and rune Numeric Types Description Unsigned integers uint8 0-255 uint16 0-65535 uint32 0-4294967295 uint64 0-18446744073709551615 Signed integers int8 -128-127 int16 -32768-32767 int32 -2147483648-2147483647 int64 -9223372036854775808-9223372036854775807 Floating Numbers float32 32 bit float64 64 bit Floating Number with imaginary part complex64 32 bit complex128 64 bit byte Alias to uint8 rune Alias to int32 In addition to above, Go also has uint and int (32 or 64 bit depending on underlying OS) and uintptr (unsigned integer to store uninterrupted bits of pointer value)