Sobes.tech
Middle+

Millised andmetüübid on Go-s?

sobes.tech AI

Vastus AI-lt

In Go, there are several main data types:

  • Boolean: bool — accepts values true or false.
  • Integer numbers: int, int8, int16, int32, int64 and their unsigned counterparts uint, uint8 (alias for byte), uint16, uint32, uint64.
  • Floating-point numbers: float32, float64.
  • Complex numbers: complex64, complex128.
  • Strings: string — immutable sequence of bytes.
  • User-defined types: structures (struct), interfaces (interface), arrays, slices (slice), maps (map), channels (chan).

Example of declaring variables of different types:

var a int = 10
var b float64 = 3.14
var c bool = true
var s string = "hello"