Skip to content

Simple Data Types

Simple data types means they only store one, that is a single value, there are four:

  • Strings
  • Numbers
  • Booleans
  • Errors

See the Standard Library docs here: https://pkg.go.dev/std

Strings

Strings in Go represent one or more characters.

Interpreted use double quotes strings will honour the escape character:

interpreted string
"this is an example \n of a string"

Raw strings don't:

raw string
`this is an example \n of a string`

Nor to raw string care about white space, so they can do multiple lines, for example:

raw string
`this is an example
of a string`

Numbers

Number in Go come in 4 flavours:

  • Integers (1, 42, -42) - int
  • Unsigned integers (0, 32, 8080) - uint
  • Floating point numbers (5.01e20, 3.1415) - float32 & float64
  • Complex numbers (0.833i) - complex64 & complex128

Booleans

Boolean is either true or false.

Error

A conventional interface representing an error condition.

type error interface {
    Error() string
}