Sobes.tech
Senior

List the main data types in Go

sobes.tech AI

Answer from AI

Main data types in Go:

  • bool — logical type (true/false)
  • string — string
  • int, int8, int16, int32, int64 — signed integer types of various lengths
  • uint, uint8, uint16, uint32, uint64, uintptr — unsigned integer types
  • byte — synonym for uint8, often used for working with bytes
  • rune — synonym for int32, represents a Unicode code point
  • float32, float64 — floating-point numbers
  • complex64, complex128 — complex numbers

Besides primitives, there are composite types:

  • array — fixed-length array
  • slice — dynamic array
  • map — hash table
  • struct — structure
  • interface — interface
  • pointer — pointer

Example of variable declarations:

var a int = 10
var b float64 = 3.14
var s string = "hello"
var flag bool = true
List the main data types in Go — Golang - sobes.tech