Go Data Types

The Go programming language has four basic data type classifications: Boolean, string, numeric, and derived types.

Boolean data types can have a value of either true or false. There are a variety of ways to declare Boolean variables or constants:

var b1 bool = true // Explicit declaration of Boolean variable
var b2 = true      // Implicit declaration; compiler infers type
b3 := true         // Simple way of declaring Boolean type var
var b4 bool        // Will default to 'false'

const B1 = false   // Boolean typed constant

String data types consist of a sequence of text characters surrounded by double quotes (e.g. “Hello!”).

There are three numeric types: integers, floats, and complex.

Derived types include array, structure, pointer, union, function, slice, interface, channel, and map types.