0Pricing
Go Academy · Lesson

Go's Built-in Types

int, float64, string, bool and their zero values

Go's Built-in Types is a free Go Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Go Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Go's Type System Overview

Go has a rich set of built-in types organized into categories:

  • Boolean: bool
  • Integer: int, int8, int16, int32, int64 and unsigned variants
  • Float: float32, float64
  • String: string
  • Complex: complex64, complex128

Integer Types

Go provides platform-dependent and fixed-size integer types:

  • int / uint — platform size (32 or 64 bit)
  • int8int64 — fixed bit widths
  • byte — alias for uint8
  • rune — alias for int32, represents a Unicode code point

Use int for general-purpose integers unless you need a specific width.

float64 and float32

Floating-point types follow IEEE 754:

package main

func main() {
    var f32 float32 = 3.14
    var f64 float64 = 3.141592653589793
    ratio := f64 / 2.0  // float64 inferred
    _ = f32
    _ = ratio
}

string Type

Strings in Go are immutable byte sequences encoded in UTF-8:

  • Double-quoted: "Hello" — supports escape sequences
  • Back-quoted: `raw string` — no escape processing, can span lines
  • len(s) returns number of bytes, not characters
  • Iterate characters with range to get runes

bool Type

The bool type has two values: true and false.

  • Zero value is false
  • Logical operators: &&, ||, !
  • Comparison operators return bool: ==, !=, <, >
  • Go does not implicitly convert integers to bool (unlike C)

Zero Values Summary

Every type has a well-defined zero value:

  • int, all numeric types → 0
  • float640.0
  • string""
  • boolfalse
  • *T, slice, map, chan, func → nil

Zero values make Go code safe — you never read garbage memory.

Numeric Literals

Go supports multiple numeric literal formats:

package main

func main() {
    dec  := 1_000_000   // digit separators
    hex  := 0xFF
    oct  := 0o777
    bin  := 0b1010
    sci  := 1.5e3       // 1500.0
    _ = dec; _ = hex; _ = oct; _ = bin; _ = sci
}

Type Sizes and Ranges

Knowing type sizes prevents overflow bugs:

  • int8: -128 to 127
  • uint8: 0 to 255
  • int16: -32768 to 32767
  • int32: ~±2.1 billion
  • int64: ~±9.2 quintillion

Use math.MaxInt64 and similar constants from the math package for exact bounds.

rune and byte

rune and byte are type aliases with semantic meaning:

  • byte = uint8 — used for raw binary/ASCII data
  • rune = int32 — used for Unicode code points

When you range over a string, Go gives you rune values — perfect for working with multi-byte UTF-8 characters like emojis.

Choosing the Right Type

Guidelines for picking numeric types:

  • Default to int for counters and indices
  • Use float64 for general floating-point math
  • Use int64 / uint64 for IDs, timestamps, large counts
  • Use int32 only when interfacing with APIs that require it
  • Avoid float32 unless working with graphics or space-constrained data

Quick Check

What is the zero value of a string variable in Go?

Recap: Built-in Types

Go's built-in types give you a solid foundation:

  • Integer family: int, int64, byte, rune
  • Floating-point: prefer float64
  • string is immutable UTF-8 bytes
  • bool with true/false
  • Every type has a zero value — no surprises

Next: constants and the powerful iota enumerator.

Practice Prompt

Experiment: declare a rune variable holding the letter 'A' and a byte variable holding 65. Print both — they should produce the same numeric value. Then try ranging over a short emoji string to see rune values in action.

Frequently asked questions

Is the “Go's Built-in Types” lesson free?

Yes — the full text of “Go's Built-in Types” is free to read here on the web, and the Go Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Go Academy course, upgrade to CoddyKit PRO.

What will I learn in “Go's Built-in Types”?

int, float64, string, bool and their zero values You practise Go Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Go Academy?

No prior experience is required. Go Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Go's Built-in Types” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Go Academy lesson?

Yes. Every Go Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Declaring Variables in Go
  2. Go's Built-in Types
  3. Constants and iota
  4. Type Conversions in Go
← Back to Go Academy